From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE04AC433E0 for ; Tue, 2 Jun 2020 04:48:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 902E420734 for ; Tue, 2 Jun 2020 04:48:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="DgwLtloB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 902E420734 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BF3E4280025; Tue, 2 Jun 2020 00:48:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA25C280012; Tue, 2 Jun 2020 00:48:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A90EA280025; Tue, 2 Jun 2020 00:48:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id 8D5A5280012 for ; Tue, 2 Jun 2020 00:48:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5977240D3 for ; Tue, 2 Jun 2020 04:48:48 +0000 (UTC) X-FDA: 76883041536.22.clock05_2fbaec2122054 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 3DF0418038E67 for ; Tue, 2 Jun 2020 04:48:48 +0000 (UTC) X-HE-Tag: clock05_2fbaec2122054 X-Filterd-Recvd-Size: 2983 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Jun 2020 04:48:47 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EFC9E2077D; Tue, 2 Jun 2020 04:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591073327; bh=sweK7AcLSH4hmA5Oly/n9RhNwy+SgaSpoljRNAOaZXk=; h=Date:From:To:Subject:In-Reply-To:From; b=DgwLtloBMylIgn8zJFOBbYKQN4Q8R7aQbjSTsMlM7Tt3u2UiAEs5fTvlp2VJREeUM 4e5JYqyvHObVApJ5vtJPiwWkDngUk+JrY/FWgR2F5073QK9v25s4N992yzEtY7FE5g h7iL5xd7n6ORYFtc3Gf78epntopp4onSJoJ/JCv0= Date: Mon, 01 Jun 2020 21:48:46 -0700 From: Andrew Morton To: akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, richard.weiyang@gmail.com, tim.c.chen@linux.intel.com, torvalds@linux-foundation.org Subject: [patch 061/128] mm/swapfile.c: offset is only used when there is more slots Message-ID: <20200602044846.skt6uJyLJ%akpm@linux-foundation.org> In-Reply-To: <20200601214457.919c35648e96a2b46b573fe1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 3DF0418038E67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Wei Yang Subject: mm/swapfile.c: offset is only used when there is more slots scan_swap_map_slots() is used to iterate swap_map[] array for an available swap entry. While after several optimizations, e.g. for ssd case, the logic of this function is a little not easy to catch. This patchset tries to clean up the logic a little: * shows the ssd/non-ssd case is handled mutually exclusively * remove some unnecessary goto for ssd case This patch (of 3): 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. Link: http://lkml.kernel.org/r/20200328060520.31449-1-richard.weiyang@gmail.com Link: http://lkml.kernel.org/r/20200328060520.31449-2-richard.weiyang@gmail.com Signed-off-by: Wei Yang Reviewed-by: Andrew Morton Cc: Tim Chen Signed-off-by: Andrew Morton --- mm/swapfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/mm/swapfile.c~mm-swapfilec-offset-is-only-used-when-there-is-more-slots +++ a/mm/swapfile.c @@ -874,11 +874,9 @@ checks: 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; } _