From patchwork Wed Jul 1 15:26:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 11636711 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 CD78D618 for ; Wed, 1 Jul 2020 15:30:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A6E0206B6 for ; Wed, 1 Jul 2020 15:30:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A6E0206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9CC5E8D004A; Wed, 1 Jul 2020 11:30:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 956348D0047; Wed, 1 Jul 2020 11:30: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 86D478D004A; Wed, 1 Jul 2020 11:30:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 731188D0047 for ; Wed, 1 Jul 2020 11:30:15 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 36717180AD807 for ; Wed, 1 Jul 2020 15:30:15 +0000 (UTC) X-FDA: 76989893190.07.guide88_33018a326e81 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 66A3A1803F9A8 for ; Wed, 1 Jul 2020 15:29:59 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dave.hansen@linux.intel.com,,RULES_HIT:30012:30034:30054:30064:30070,0,RBL:134.134.136.24:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04yrpsk3gje8y3eo74yqjkgzgg79hycwmgzs5unp3u9ugoaquu357oxktrryd4a.9rpcgjn44ixs4pfu9u8o6f63ia7pfxnnp1tr7yi8gxixtmfereydrsryjz9seci.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: guide88_33018a326e81 X-Filterd-Recvd-Size: 4890 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Jul 2020 15:29:58 +0000 (UTC) IronPort-SDR: KM6avptItCpIHqXxCTwKsNh2zuM1lkG1zKPioWqj4vTUjPL+e6ktyLlSB7XCKpVnaZngbwYHZe c75wNi3tkvtw== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="148158693" X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="148158693" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.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> X-Rspamd-Queue-Id: 66A3A1803F9A8 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: 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;