Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2214158ybz; Sat, 18 Apr 2020 18:40:51 -0700 (PDT) X-Google-Smtp-Source: APiQypKqEPrqoMblDza/qQpOnHBbxXUkmWYro9RWlCz6HN9zBzGNE+leIxAZg+9FG8lV7/o7ngyZ X-Received: by 2002:a05:6402:206c:: with SMTP id bd12mr8930526edb.287.1587260451684; Sat, 18 Apr 2020 18:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587260451; cv=none; d=google.com; s=arc-20160816; b=OkNDGNqD+r6+I8OvlMeIN0sGAqgcj0xMFzDF/4lTkOXcTbL+D6s8yWs29qhNc24tf+ tWrgLZwcms5C+mce0Kd3IIJKJvkRkD6EX1ryDHDPedu8Ud1H4jkaaB5AqSlNrdhjLU+F RUTjuNWao4+7gAYIHjLw1lgWcWeJVy0A/tmcHtUopldPGQ9U6KMGe4pnRVilloR/h1zt lkK3lNwoq/Ks4ncbMtOVgy7v2Lh928oLtrVImMYSixnkESGMXdAx+oRmkE1NaR8k9xTg jF0csNWAxCNjEl3t0y2yrN/UjjcHl+xF7xYpEZVsvjc2YR2Bs9CQfUToCdkfAKPJpfb+ Uc5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=YQ0IcD0MJa87Cl5cTZ+wxBcgc8xap3RC76BVjfIWVzU=; b=yOYEldZUzszj1N9K5Wb4K0Yy9cSDkE2s/nqZ/G/Lg3Xq/uM+1UJ7nxqLmIbxq+K5ln nYR07g7jaITvY9V+dNEGgzeP/Yu5AwVT8VLRWgdQeCw6fsPwLsaXucTvebpaPU6xMrG4 7oDGR+48KRVE1QQiCMzMZqtZLNMmKlRrohUe0bgMDfMfQT7tk6l+kXbYXZpEL8LPcA96 xLeSOSDLgp0+r5P4Q+2zxf+IST6XXAkhavHHem3TYGAQt0l3zeJfe4/+G5x6oTXfYr3C ImKmCxk2xFq7jv6H0Joao3uzEhjkrv8xzOUc28THSoe1Va5vCTEQSLpFRrOK6yABWzwd 1u7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tD75O/Fh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a19si16880215ejt.117.2020.04.18.18.40.28; Sat, 18 Apr 2020 18:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tD75O/Fh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726011AbgDSBjd (ORCPT + 99 others); Sat, 18 Apr 2020 21:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725879AbgDSBjc (ORCPT ); Sat, 18 Apr 2020 21:39:32 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC514C061A0C for ; Sat, 18 Apr 2020 18:39:30 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id t12so1220007edw.3 for ; Sat, 18 Apr 2020 18:39:30 -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; bh=YQ0IcD0MJa87Cl5cTZ+wxBcgc8xap3RC76BVjfIWVzU=; b=tD75O/FhAiU4tZlZn9qCLTOtwiBMTsQyy00zKr8jfD0SDT/f3eOlUGzOufRnPAAoF9 I1st4PwIcwVtGKwAMlZ4my/xrbNqmEQtJhw6/jhriv0h185vZFB7nPbIG5FJ+u16OqZn cGAtjUJqvcLR8hzRG97pFV4xaPf4qVTGK3WtUa43hyU1OwHZzQ54+ARTkj865FqFrcBg FthwoEEPalDoI6PZu9z1/93deBEl2du4YAFaAvz2NZx+odT7qSOwE5Imk6bhd9B0LKV0 8UW4n/TEPNKHzxXVr2LwrB6rPCb9Y0gxpJoFh055ywb0OcJOjrKukGTAD4DcgJ2sSSGr aIaA== 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; bh=YQ0IcD0MJa87Cl5cTZ+wxBcgc8xap3RC76BVjfIWVzU=; b=AnH+bTW9bryKkoR2hcq1VBE+bUauq4K1U9dfcOTswTKDp9OdRVkqOMr6b16e1Fxucv 19YnxyyRuWhX0r2BAh5wZMUq9M7ktsDkcGvHpnxjQsnjSi1Y0h9FvNUEOra6mxxMsLBj 4Zp/JDgJxRln2jMIUEv+9sg0A2VLoEEi6TZTPkz0QRG7+xXFwXrxyD+iOmVPQyxD/FjE L+LD/VdlsL03fLLhpkO0iHJOLZDcrJJ39b43Ih9rrzkv0b37PUIA4E2zaFIZFmIIzyef XsmEnCJvoh1ptNxSFJwrejhUMvLPO1dPtC0r1zjv4GtmLgm66dnGBj2MhYCauJJEkoMe H3Bw== X-Gm-Message-State: AGi0PuZPVyBm0oPTMIwA7/eG3rCC8UOkS4X7teo5+8IkYIaOewzeWBj9 5FG8QCidqnPcML5MZsuECZw= X-Received: by 2002:a50:cd89:: with SMTP id p9mr8914024edi.188.1587260369506; Sat, 18 Apr 2020 18:39:29 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id k33sm3345395edc.18.2020.04.18.18.39.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Apr 2020 18:39:28 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, ying.huang@intel.com, Wei Yang Subject: [PATCH 1/4] mm/swapfile.c: found_free could be represented by (tmp < max) Date: Sun, 19 Apr 2020 01:39:18 +0000 Message-Id: <20200419013921.14390-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is not necessary to use the variable found_free to record the status. Just check tmp and max is enough. Signed-off-by: Wei Yang --- mm/swapfile.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index c457f3be6944..654bad5173bc 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -601,7 +601,6 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si, { struct percpu_cluster *cluster; struct swap_cluster_info *ci; - bool found_free; unsigned long tmp, max; new_cluster: @@ -623,8 +622,6 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si, 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 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si, } 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) -- 2.23.0