Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp723660ybt; Wed, 1 Jul 2020 08:32:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3p4S0NachCrmIAwL8YNOTQ1vwAySeFZyty8+jJ9OOdQf3WvtfteAl4lmeFmbZvEANvd0H X-Received: by 2002:a05:6402:164f:: with SMTP id s15mr30067980edx.239.1593617565386; Wed, 01 Jul 2020 08:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593617565; cv=none; d=google.com; s=arc-20160816; b=0Bjzrk3z7iCC4zxNM1aPyTgIfzg+AP+zhTaTHgWzWmY98+XnX8mp9Hcu3MorawtKzF TgaZvjiS5yzQnbWNSRFwphxK7PcmuPPq8ezznUPYm1BnNP0pYrrQlTuFo+3ejSvrEqez P8eleolB/5rmsUgvz1mvTHEjiLo7wZfu4amqjtHr0GC1ImwovGS3SRuNfAIeD8qjrGIV ova6SGB7ZRuxXdUROhrlODpr42FjkKIene3Yee4hWvKyPhrcI+1ReW/V3TNki/NmhyBp irS6+Qk2WDJ/O3/eM2eyNoJ6ELSOIzhDJ+mSMCyS0f/NLMOZUwgLlomNAj8ZAxFbKh5F S6Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject:ironport-sdr:ironport-sdr; bh=SwR4G+ULofc5XQ2oQbpHepvpLNL9OREywoDtjhejlYk=; b=lxCB+W0KGN3/BbWpCumJXHGX2I6eN2se6wgj7C6eofOt8mHYuCKjT+XrE+351V5rac w8lStMhmUcI22xhDjq/hmSgLuNemuwVs7D00A0gepVxvVluxALQDYqkA3bSqs0QPzNc7 j5DECSoMvvzkRqn7VrzIvhZW/tSO9i/pabAVbXg6ag5GAQTCMKyhIMEiKG6ubNefR4qI GssR8a36PpoGcDRF6dNT9kqz9c2kZWEfqfxrbImVsEhM9FaJU5RqKNgxcuHdv6HUkQGf +83x7W5xe2M7wr5DTfTtb+a4b42juw5XjUZYL2aImWp8UE09znnI3Ns50ybkWDK8BK37 CtdQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si3991134ejw.686.2020.07.01.08.32.11; Wed, 01 Jul 2020 08:32:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732036AbgGAPaC (ORCPT + 99 others); Wed, 1 Jul 2020 11:30:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:50999 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731999AbgGAP36 (ORCPT ); Wed, 1 Jul 2020 11:29:58 -0400 IronPort-SDR: CXPyJREHJuFWJlytuaOLl0nGFaPObY52Ja0eXmtQZEqEllEtwltZlBnx+mWBSGr8KvZt8EzIg4 LJ7dgdUtO2/g== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="164629248" X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="164629248" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2020 08:29:57 -0700 IronPort-SDR: Ismp2V6GfaWh0PhhqHlR4SeVuXkAW4a/LP+kKW3DVQREFdbuUd2Hp5TEkyqyIQX6x+Db6tT6Ow M3O+yVRDHeqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="312726341" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga008.jf.intel.com with ESMTP; 01 Jul 2020 08:29:57 -0700 Subject: [PATCH 3/3] mm/vmscan: replace implicit RECLAIM_ZONE checks with explicit checks To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , ben.widawsky@intel.com, alex.shi@linux.alibaba.com, dwagner@suse.de, tobin@kernel.org, cl@linux.com, akpm@linux-foundation.org, ying.huang@intel.com, dan.j.williams@intel.com, cai@lca.pw From: Dave Hansen Date: Wed, 01 Jul 2020 08:26:27 -0700 References: <20200701152621.D520E62B@viggo.jf.intel.com> In-Reply-To: <20200701152621.D520E62B@viggo.jf.intel.com> Message-Id: <20200701152627.8761147E@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen RECLAIM_ZONE was assumed to be unused because it was never explicitly used in the kernel. However, there were a number of places where it was checked implicitly by checking 'node_reclaim_mode' for a zero value. These zero checks are not great because it is not obvious what a zero mode *means* in the code. Replace them with a helper which makes it more obvious: node_reclaim_enabled(). This helper also provides a handy place to explicitly check the RECLAIM_ZONE bit itself. Check it explicitly there to make it more obvious where the bit can affect behavior. This should have no functional impact. Signed-off-by: Dave Hansen Cc: Ben Widawsky Cc: Alex Shi Cc: Daniel Wagner Cc: "Tobin C. Harding" Cc: Christoph Lameter Cc: Andrew Morton Cc: Huang Ying Cc: Dan Williams Cc: Qian Cai Cc: Daniel Wagner -- Note: This is not cc'd to stable. It does not fix any bugs. --- b/include/linux/swap.h | 7 +++++++ b/mm/khugepaged.c | 2 +- b/mm/page_alloc.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff -puN include/linux/swap.h~mm-vmscan-node_reclaim_mode_helper include/linux/swap.h --- a/include/linux/swap.h~mm-vmscan-node_reclaim_mode_helper 2020-07-01 08:22:13.650955330 -0700 +++ b/include/linux/swap.h 2020-07-01 08:22:13.659955330 -0700 @@ -12,6 +12,7 @@ #include #include #include +#include #include struct notifier_block; @@ -374,6 +375,12 @@ extern int sysctl_min_slab_ratio; #define node_reclaim_mode 0 #endif +static inline bool node_reclaim_enabled(void) +{ + /* Is any node_reclaim_mode bit set? */ + return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); +} + extern void check_move_unevictable_pages(struct pagevec *pvec); extern int kswapd_run(int nid); diff -puN mm/khugepaged.c~mm-vmscan-node_reclaim_mode_helper mm/khugepaged.c --- a/mm/khugepaged.c~mm-vmscan-node_reclaim_mode_helper 2020-07-01 08:22:13.652955330 -0700 +++ b/mm/khugepaged.c 2020-07-01 08:22:13.660955330 -0700 @@ -709,7 +709,7 @@ static bool khugepaged_scan_abort(int ni * If node_reclaim_mode is disabled, then no extra effort is made to * allocate memory locally. */ - if (!node_reclaim_mode) + if (!node_reclaim_enabled()) return false; /* If there is a count for this node already, it must be acceptable */ diff -puN mm/page_alloc.c~mm-vmscan-node_reclaim_mode_helper mm/page_alloc.c --- a/mm/page_alloc.c~mm-vmscan-node_reclaim_mode_helper 2020-07-01 08:22:13.655955330 -0700 +++ b/mm/page_alloc.c 2020-07-01 08:22:13.662955330 -0700 @@ -3733,7 +3733,7 @@ retry: if (alloc_flags & ALLOC_NO_WATERMARKS) goto try_this_zone; - if (node_reclaim_mode == 0 || + if (!node_reclaim_enabled() || !zone_allows_reclaim(ac->preferred_zoneref->zone, zone)) continue; _