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 5EFBBC433DF for ; Tue, 2 Jun 2020 04:49:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C5AE206C3 for ; Tue, 2 Jun 2020 04:49:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="PtKC6uLs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C5AE206C3 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 7D45528002C; Tue, 2 Jun 2020 00:49:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 786C3280012; Tue, 2 Jun 2020 00:49:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69AEA28002C; Tue, 2 Jun 2020 00:49:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id 507EC280012 for ; Tue, 2 Jun 2020 00:49:03 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1E3913ABF for ; Tue, 2 Jun 2020 04:49:03 +0000 (UTC) X-FDA: 76883042166.21.fowl51_31e39204f1731 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 08476180442C2 for ; Tue, 2 Jun 2020 04:49:03 +0000 (UTC) X-HE-Tag: fowl51_31e39204f1731 X-Filterd-Recvd-Size: 3110 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Jun 2020 04:49:02 +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 B63072077D; Tue, 2 Jun 2020 04:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591073342; bh=r8HXVSyH9rJNEJN2gN9y0WfVdLm1JjMa1WftpZYQ03Q=; h=Date:From:To:Subject:In-Reply-To:From; b=PtKC6uLsEWPDRULD+4zCt3GCO3cLz94WcRxA5IyBa8RkeX6kempVdw3V7PVPcTcu4 YnIB3a8ZKpLXA1KQZ2XpI5DDNnrXdaoRbADGZAPjcjjdLR2MJ6jueCE+jx9EQV4W75 H5Y5+5B5DDRLMN0zfxQpeKIq4UAEvLNsec09vA8Y= Date: Mon, 01 Jun 2020 21:49:01 -0700 From: Andrew Morton To: akpm@linux-foundation.org, hughd@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, richard.weiyang@gmail.com, tim.c.chen@linux.intel.com, torvalds@linux-foundation.org, ying.huang@intel.com Subject: [patch 066/128] mm/swapfile.c: found_free could be represented by (tmp < max) Message-ID: <20200602044901.WNeh7EcJy%akpm@linux-foundation.org> In-Reply-To: <20200601214457.919c35648e96a2b46b573fe1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 08476180442C2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: found_free could be represented by (tmp < max) This is not necessary to use the variable found_free to record the status. Just check tmp and max is enough. Link: http://lkml.kernel.org/r/20200421213824.8099-1-richard.weiyang@gmail.com Signed-off-by: Wei Yang Reviewed-by: "Huang, Ying" Cc: Tim Chen Cc: Hugh Dickins Signed-off-by: Andrew Morton --- mm/swapfile.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- a/mm/swapfile.c~mm-swapfilec-found_free-could-be-represented-by-tmp-max +++ a/mm/swapfile.c @@ -601,7 +601,6 @@ static bool scan_swap_map_try_ssd_cluste { struct percpu_cluster *cluster; struct swap_cluster_info *ci; - bool found_free; unsigned long tmp, max; new_cluster: @@ -623,8 +622,6 @@ new_cluster: return false; } - found_free = false; - /* * Other CPUs can use our cluster if they can't find a free cluster, * check if there is still free entry in the cluster @@ -638,21 +635,19 @@ new_cluster: } ci = lock_cluster(si, tmp); while (tmp < max) { - if (!si->swap_map[tmp]) { - found_free = true; + if (!si->swap_map[tmp]) break; - } tmp++; } unlock_cluster(ci); - if (!found_free) { + if (tmp >= max) { cluster_set_null(&cluster->index); goto new_cluster; } cluster->next = tmp + 1; *offset = tmp; *scan_base = tmp; - return found_free; + return tmp < max; } static void __del_from_avail_list(struct swap_info_struct *p) _