From patchwork Sat Mar 28 06:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11463415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87CDC81 for ; Sat, 28 Mar 2020 06:06:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 547D3206F2 for ; Sat, 28 Mar 2020 06:06:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kv9L3cKq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 547D3206F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 94A596B0032; Sat, 28 Mar 2020 02:06:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D3A56B0036; Sat, 28 Mar 2020 02:06:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 723696B0037; Sat, 28 Mar 2020 02:06:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 5AE6A6B0032 for ; Sat, 28 Mar 2020 02:06:12 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 25FDF582D for ; Sat, 28 Mar 2020 06:06:12 +0000 (UTC) X-FDA: 76643735784.14.place09_53391dad89d41 X-Spam-Summary: 2,0,0,0dc8a0036c0afbaa,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3868:3870:3871:4321:5007:6119:6261:6653:7514:7558:8540:9413:10004:11026:11658:11914:12297:12517:12519:12555:12895:13069:13146:13230:13311:13357:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30012:30054,0,RBL:209.85.221.66:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: place09_53391dad89d41 X-Filterd-Recvd-Size: 3640 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Sat, 28 Mar 2020 06:06:11 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id 31so14323968wrs.3 for ; Fri, 27 Mar 2020 23:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WtlQPkdICdSif60EiclWGWU5XZBZP+qLNsbVEnNZNqA=; b=Kv9L3cKqFvmEx2bcOl2zy+8nyIsg18Cn4Gv2VNxdcuX3P2x0xh2EWcGYMXgbe26TNf LqipxAyjmPC18C7Zxs/jnb+k+EINirBcxEoFq7Zfk6BbK0qdArjM6V+jiVSt9F4IoaGK FHRlqyXJGvN1zUDY7DPKLrfC4u3/h1G63SehM4kfjqfC/Dc4Z0prJdQA4pRLQxQ4QpEn Cl9CXW3tXWgUcJVzrpG0rjWlbLOFF4JHAREVxWz8Rh5sqKGkC8IM/TtkRCVwanNVz0I3 Vrs49MQK69nrpjctnWPbBeP1pWkMNjZgZ2qOtOMUOHZBTgZRu9b+u8s9IoGRdJvV/vEH YWTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WtlQPkdICdSif60EiclWGWU5XZBZP+qLNsbVEnNZNqA=; b=K762TXNSxNDdKoolXIIkX3ETFZgxTKc9MRdFwKTapwV3JI11TXOmoQBOIFKauwsywr 0EWHJTmAQe9thZcZF15skGx/oo6nPYM6aGAmArKeoVfDUoHydWsRyVVo1j2a6ArsVCwz oT6+rMIZt+puaCwg1iEOaACXA33Qnu5cr6PQFwb4ZptnEPVRDTJsB1IQWv/14UTgZ7Ob FbRZ5j2pxV2BUh3WIyh31XaIU1OEDMmXuzhTNikWTy1qI22yly3x2TIjVEXrk7nVTCA9 7ofgoBjFkQjCbNe6XUX6PW+Lbfqo0Kxr5AZptBMphpYjD68cxRiqcf349kvOS8gOQWMc GTnA== X-Gm-Message-State: ANhLgQ0Yjaem7nNikyh4eIMZr23wRgp6kp8P09z9oUJkQoY0YQtpF1Js FQwpo0l8zlc2oI/slj8V4Eg= X-Google-Smtp-Source: ADFU+vtc/KFk/g8A31nX3lHxrJRjKhryKYhbhqJkJetNubeeO+aN4etZLQPF1fBp4kmLr/8C6l3C3Q== X-Received: by 2002:a5d:464e:: with SMTP id j14mr3219727wrs.339.1585375570783; Fri, 27 Mar 2020 23:06:10 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id w204sm11264719wma.1.2020.03.27.23.06.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Mar 2020 23:06:10 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 1/3] mm/swapfile.c: offset is only used when there is more slots Date: Sat, 28 Mar 2020 06:05:18 +0000 Message-Id: <20200328060520.31449-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200328060520.31449-1-richard.weiyang@gmail.com> References: <20200328060520.31449-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When si->cluster_nr is zero, function would reach done and return. The increased offset would not be used any more. This means we can move the offset increment into the if clause. This brings a further code cleanup possibility. Signed-off-by: Wei Yang --- mm/swapfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 6b6e41967bf3..52afb74fc3d1 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -871,11 +871,9 @@ static int scan_swap_map_slots(struct swap_info_struct *si, else goto done; } - /* non-ssd case */ - ++offset; /* non-ssd case, still more slots in cluster? */ - if (si->cluster_nr && !si->swap_map[offset]) { + if (si->cluster_nr && !si->swap_map[++offset]) { --si->cluster_nr; goto checks; } From patchwork Sat Mar 28 06:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11463417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D21AF92A for ; Sat, 28 Mar 2020 06:06:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9F8DE206F2 for ; Sat, 28 Mar 2020 06:06:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HHkzn15h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F8DE206F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A81476B0036; Sat, 28 Mar 2020 02:06:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A32946B0037; Sat, 28 Mar 2020 02:06:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D2336B006C; Sat, 28 Mar 2020 02:06:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id 6F9D66B0036 for ; Sat, 28 Mar 2020 02:06:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 42B6F52D6 for ; Sat, 28 Mar 2020 06:06:13 +0000 (UTC) X-FDA: 76643735826.20.cars95_535d92d9e3339 X-Spam-Summary: 2,0,0,bcaa25729283413d,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:4321:5007:6119:6120:6261:6653:7514:7558:9413:9592:10004:11026:11658:11914:12297:12517:12519:12555:12895:13069:13161:13229:13255:13311:13357:14181:14384:14394:14687:14721:21080:21444:21627:21666:30012:30054,0,RBL:209.85.221.65:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: cars95_535d92d9e3339 X-Filterd-Recvd-Size: 4014 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Sat, 28 Mar 2020 06:06:12 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id w10so14374369wrm.4 for ; Fri, 27 Mar 2020 23:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BUUZ6nzVONK+blk4chCmCKkx96rDIegQpK/XZUn6XmE=; b=HHkzn15hN+SVYEBnyxtPwckF/8L7+u1V9LuYJGyb5xwQ/FGTMaqBLEzHiDa5eqa43I VMOmVU4zoM+pP91+5XGLfIgDq/ihi6Qvh688pTQQMXOyM57xIhTiKrIngmkpNujmoUTj 1PTCyMvBh1QcKUoAWqVq44DXK0xAeyR/wTPNlPRX7RgOyOgtj4EsTmg01H0vGqyuBo0a l75GUu1rWZT5gQzS4xjcWorO7XrebX+QzchVh/WwQhRrkCsbtEjCS7/WAlEfVhBDS9eO Fz8gNdXJoF0VHRuPOlWDdHWXe3OsdSo3Ws8zus4O6SZCyaIl1qUvcKcIXbOdjeWy1+Gn MBaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BUUZ6nzVONK+blk4chCmCKkx96rDIegQpK/XZUn6XmE=; b=okIp+Z7PlRjc18XX0IXWwdkjotOL+4xcjfb5oDqDtwrY0DdHj7mKUsxFi25Vb/a1c4 Y6R9eFYlE+iBSaEvHv5H5kWomlNEweNsjyyl7Eg4J4mYZ7QD/B8gXIfzu1FMOrN1TRWP SHYmyObYofhjdfs5WtjINGDeV8aLVnxmuyTRffgPdQafEPiKPOdm4IHMVsaPyovbpWLQ uNtrDeTB0Z7yXTEsH4g9dV2mhhyGWf2ZmQR9oS2RdxmmyXkDif7HT5oPC/FNToR4aVLW jq38XZQU2AQddapryNJOJS8XZPvGK28Gr9cRANhCz3S+upoIBYg72I1Q3BPqxkDuXp6V Tv0Q== X-Gm-Message-State: ANhLgQ2TYeq7i9VULg33iQW3o9xL+BQAjpZ0U7NX+Jpz78ASyoPsH7He RhT9IFEZUiWimUEqCO9KGIY= X-Google-Smtp-Source: ADFU+vuoscb5qUswTMJY9JhIFuKoRbiDEjYT3ClleQdVv32S5WeSAfMrJCNUnVEM63WwVMIwO+OU7w== X-Received: by 2002:adf:9b9d:: with SMTP id d29mr3229523wrc.294.1585375571758; Fri, 27 Mar 2020 23:06:11 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id m19sm11229021wml.48.2020.03.27.23.06.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Mar 2020 23:06:11 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 2/3] mm/swapfile.c: explicitly show ssd/non-ssd is handled mutually exclusive Date: Sat, 28 Mar 2020 06:05:19 +0000 Message-Id: <20200328060520.31449-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200328060520.31449-1-richard.weiyang@gmail.com> References: <20200328060520.31449-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000080, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The code shows if this is ssd, it will jump to specific tag and skip the following code for non-ssd. Let's use "else if" to explicitly show the mutually exclusion for ssd/non-ssd to reduce ambiguity. Signed-off-by: Wei Yang --- mm/swapfile.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 52afb74fc3d1..adf48d4b1b63 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -760,9 +760,7 @@ static int scan_swap_map_slots(struct swap_info_struct *si, goto checks; else goto scan; - } - - if (unlikely(!si->cluster_nr--)) { + } else if (unlikely(!si->cluster_nr--)) { if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER) { si->cluster_nr = SWAPFILE_CLUSTER - 1; goto checks; @@ -870,10 +868,8 @@ static int scan_swap_map_slots(struct swap_info_struct *si, goto checks; else goto done; - } - - /* non-ssd case, still more slots in cluster? */ - if (si->cluster_nr && !si->swap_map[++offset]) { + } else if (si->cluster_nr && !si->swap_map[++offset]) { + /* non-ssd case, still more slots in cluster? */ --si->cluster_nr; goto checks; } From patchwork Sat Mar 28 06:05:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11463419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F00AD92A for ; Sat, 28 Mar 2020 06:06:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD57C206F2 for ; Sat, 28 Mar 2020 06:06:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X+h/l6FE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD57C206F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 94DD26B0037; Sat, 28 Mar 2020 02:06:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 860346B006C; Sat, 28 Mar 2020 02:06:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 725D06B006E; Sat, 28 Mar 2020 02:06:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 5AB056B0037 for ; Sat, 28 Mar 2020 02:06:15 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 665D9582D for ; Sat, 28 Mar 2020 06:06:14 +0000 (UTC) X-FDA: 76643735868.04.line65_5388fb80c752c X-Spam-Summary: 2,0,0,4b2b49ebdb52551a,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:3872:4250:4321:5007:6119:6120:6261:6653:7514:7558:7901:9413:10004:11026:11658:11914:12043:12297:12438:12517:12519:12555:12895:13069:13311:13357:14181:14384:14394:14687:14721:21080:21444:21627:21666:30012:30054,0,RBL:209.85.128.67:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: line65_5388fb80c752c X-Filterd-Recvd-Size: 4026 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Sat, 28 Mar 2020 06:06:13 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id d1so15042157wmb.2 for ; Fri, 27 Mar 2020 23:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QyxtkEAHQnaf1QErBru4etFEtt1eRtjW95hNmE2s3Y4=; b=X+h/l6FE0bZBg5LxVz5E/0bUlMhHU9T1/Pty0E7jAPNp8YGpQmZuECTwXBC/STO4PS 1WrNZs7bApj1wo0UThwBWVhTIjuxuPK5tqxrrvgRcrQdntAEg2wuefW1GVTP/okQ9GPO IZ4VN9amnTEdLd9SS4jnG0IRb0Huj/ca7GzdJtWrE5k+PnNbEqTYK+hudGZrZoJ+wCpF Kcpu6zPqmdYAD+t0C0HiQwD/raXAfe0yktUjhWXlmGSRSZSKGfnDtiY3VHd83D3Y7WmW FAV86wJ80f2wVv4fqwOBPoEazwcaKQQ31RKnd/6vt1Gs4WfTXFHi3eGhowoip9IClHf8 Mjlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QyxtkEAHQnaf1QErBru4etFEtt1eRtjW95hNmE2s3Y4=; b=FxLFrs1jXLWWs+HAa9pd1sdr/5E+LH+xv3L63G+ydjX+MUzdNU009ShCbxX4mAUdG0 Mr/0AgmbCpGCaFHzsXgFWLguTH8bPfARuKL4MezqpixsQcGoCkvd+N3jDuZJpOUp4Jof qw44Kba660E6o13KBkciMYSgZEb00z84l2pD6kerTfTl0SWwaEvCLlzJ3HNc/n6hgyxL aHg9RhGftZvbPBXY4JfNrrmuTAr9tReDiVW/OqW5GnJJuLcba8B0Bs1EnifneA3wWjT/ NUBlH/e3q2N0+7V7lUybMwBfqu668WOh8AezLcOjQJVY1nqNIFYdSKHS0Dp5gWrw16Un OOTQ== X-Gm-Message-State: ANhLgQ2r1DCOFyLv+0d62UnKXmG2hkVK2RFmBFsIN4Kg93QRFB/+uaye uUR72SbcUYKycCECJ+j7mqU= X-Google-Smtp-Source: ADFU+vsnyZXOBaYycEjCrZ8ZHd1gj6YWTO9Um/rYrjUd4y77Fln6LQENeY2av+WepOyAUMPx416g7w== X-Received: by 2002:a1c:a7c4:: with SMTP id q187mr58664wme.88.1585375572913; Fri, 27 Mar 2020 23:06:12 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id d124sm10967627wmd.37.2020.03.27.23.06.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Mar 2020 23:06:12 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 3/3] mm/swapfile.c: remove the unnecessary goto for SSD case Date: Sat, 28 Mar 2020 06:05:20 +0000 Message-Id: <20200328060520.31449-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200328060520.31449-1-richard.weiyang@gmail.com> References: <20200328060520.31449-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now we can see there is redundant goto for SSD case. In these two places, we can just let the code walk through to the correct tag instead of explicitly jump to it. Let's remove them for better readability. Signed-off-by: Wei Yang --- mm/swapfile.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index adf48d4b1b63..f903e5a165d5 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -756,9 +756,7 @@ static int scan_swap_map_slots(struct swap_info_struct *si, /* SSD algorithm */ if (si->cluster_info) { - if (scan_swap_map_try_ssd_cluster(si, &offset, &scan_base)) - goto checks; - else + if (!scan_swap_map_try_ssd_cluster(si, &offset, &scan_base)) goto scan; } else if (unlikely(!si->cluster_nr--)) { if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER) { @@ -866,8 +864,6 @@ static int scan_swap_map_slots(struct swap_info_struct *si, if (si->cluster_info) { if (scan_swap_map_try_ssd_cluster(si, &offset, &scan_base)) goto checks; - else - goto done; } else if (si->cluster_nr && !si->swap_map[++offset]) { /* non-ssd case, still more slots in cluster? */ --si->cluster_nr;