From patchwork Wed Jul 1 15:26:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 11636707 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 13E1860D for ; Wed, 1 Jul 2020 15:29:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D4A1520760 for ; Wed, 1 Jul 2020 15:29:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4A1520760 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 D02808D0048; Wed, 1 Jul 2020 11:29:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CB3708D0047; Wed, 1 Jul 2020 11:29:56 -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 BC9B08D0048; Wed, 1 Jul 2020 11:29:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id A82848D0047 for ; Wed, 1 Jul 2020 11:29:56 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 67883180AD807 for ; Wed, 1 Jul 2020 15:29:56 +0000 (UTC) X-FDA: 76989892392.18.power39_2600dd426e81 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id BC572100EDBC5 for ; Wed, 1 Jul 2020 15:29:55 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dave.hansen@linux.intel.com,,RULES_HIT:30041:30054:30064:30069:30070:30090,0,RBL:192.55.52.120:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04yriw8jo45fcwtd6bffu3omb5p3oop7npxuzafgaawqp3tqqd97471k4n681c6.isemfeihico8qjftc8ehcjuy6mdouehwk67eud3e5fzujp6dadb1mwqm8qsumim.o-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: power39_2600dd426e81 X-Filterd-Recvd-Size: 5787 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Jul 2020 15:29:54 +0000 (UTC) IronPort-SDR: nPSltx0+6OICfdRI+p/lw9xQXKuSLw+VKBr2bfybDYs2wCJt2BrKcXhW2FJh9Mon8DlCLO7hr/ opmGbWMHBYUA== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="144120717" X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="144120717" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2020 08:29:53 -0700 IronPort-SDR: MATPxC2NxKlfAgUDaGpHd5kBCQSE7i0usf4jUnqYf9Kqooj4xzplQR/F0CEfB8wloMMj/uwBQ+ 6nCJR6paZMvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="295592133" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga002.jf.intel.com with ESMTP; 01 Jul 2020 08:29:53 -0700 Subject: [PATCH 1/3] mm/vmscan: restore zone_reclaim_mode ABI 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,stable@vger.kernel.org From: Dave Hansen Date: Wed, 01 Jul 2020 08:26:23 -0700 References: <20200701152621.D520E62B@viggo.jf.intel.com> In-Reply-To: <20200701152621.D520E62B@viggo.jf.intel.com> Message-Id: <20200701152623.384AF0A7@viggo.jf.intel.com> X-Rspamd-Queue-Id: BC572100EDBC5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 I went to go add a new RECLAIM_* mode for the zone_reclaim_mode sysctl. Like a good kernel developer, I also went to go update the documentation. I noticed that the bits in the documentation didn't match the bits in the #defines. The VM never explicitly checks the RECLAIM_ZONE bit. The bit is, however implicitly checked when checking 'node_reclaim_mode==0'. The RECLAIM_ZONE #define was removed in a cleanup. That, by itself is fine. But, when the bit was removed (bit 0) the _other_ bit locations also got changed. That's not OK because the bit values are documented to mean one specific thing and users surely rely on them meaning that one thing and not changing from kernel to kernel. The end result is that if someone had a script that did: sysctl vm.zone_reclaim_mode=1 That script went from doing nothing to writing out pages during node reclaim after the commit in question. That's not great. Put the bits back the way they were and add a comment so something like this is a bit harder to do again. Update the documentation to make it clear that the first bit is ignored. Signed-off-by: Dave Hansen Fixes: 648b5cf368e0 ("mm/vmscan: remove unused RECLAIM_OFF/RECLAIM_ZONE") 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 Cc: stable@vger.kernel.org Acked-by: David Rientjes --- b/Documentation/admin-guide/sysctl/vm.rst | 10 +++++----- b/mm/vmscan.c | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff -puN Documentation/admin-guide/sysctl/vm.rst~mm-vmscan-restore-old-zone_reclaim_mode-abi Documentation/admin-guide/sysctl/vm.rst --- a/Documentation/admin-guide/sysctl/vm.rst~mm-vmscan-restore-old-zone_reclaim_mode-abi 2020-07-01 08:22:11.354955336 -0700 +++ b/Documentation/admin-guide/sysctl/vm.rst 2020-07-01 08:22:11.360955336 -0700 @@ -948,11 +948,11 @@ that benefit from having their data cach left disabled as the caching effect is likely to be more important than data locality. -zone_reclaim may be enabled if it's known that the workload is partitioned -such that each partition fits within a NUMA node and that accessing remote -memory would cause a measurable performance reduction. The page allocator -will then reclaim easily reusable pages (those page cache pages that are -currently not used) before allocating off node pages. +Consider enabling one or more zone_reclaim mode bits if it's known that the +workload is partitioned such that each partition fits within a NUMA node +and that accessing remote memory would cause a measurable performance +reduction. The page allocator will take additional actions before +allocating off node pages. Allowing zone reclaim to write out pages stops processes that are writing large amounts of data from dirtying pages on other nodes. Zone diff -puN mm/vmscan.c~mm-vmscan-restore-old-zone_reclaim_mode-abi mm/vmscan.c --- a/mm/vmscan.c~mm-vmscan-restore-old-zone_reclaim_mode-abi 2020-07-01 08:22:11.356955336 -0700 +++ b/mm/vmscan.c 2020-07-01 08:22:11.362955336 -0700 @@ -4090,8 +4090,13 @@ module_init(kswapd_init) */ int node_reclaim_mode __read_mostly; -#define RECLAIM_WRITE (1<<0) /* Writeout pages during reclaim */ -#define RECLAIM_UNMAP (1<<1) /* Unmap pages during reclaim */ +/* + * These bit locations are exposed in the vm.zone_reclaim_mode sysctl + * ABI. New bits are OK, but existing bits can never change. + */ +#define RECLAIM_ZONE (1<<0) /* Run shrink_inactive_list on the zone */ +#define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */ +#define RECLAIM_UNMAP (1<<2) /* Unmap pages during reclaim */ /* * Priority for NODE_RECLAIM. This determines the fraction of pages From patchwork Wed Jul 1 15:26:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 11636709 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 2AD6F60D for ; Wed, 1 Jul 2020 15:30:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC2B320760 for ; Wed, 1 Jul 2020 15:30:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC2B320760 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 3B22B8D0049; Wed, 1 Jul 2020 11:30:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3638C8D0047; Wed, 1 Jul 2020 11:30:13 -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 251E88D0049; Wed, 1 Jul 2020 11:30:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 0FEB48D0047 for ; Wed, 1 Jul 2020 11:30:13 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C3458824805A for ; Wed, 1 Jul 2020 15:30:12 +0000 (UTC) X-FDA: 76989893064.28.hill12_0b1441226e81 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id A165A6C2C for ; Wed, 1 Jul 2020 15:30:12 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dave.hansen@linux.intel.com,,RULES_HIT:30054:30064:30070,0,RBL:134.134.136.20:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04yrf84to4zcjbh6e1h33uyd3ja5rycbg637twkf9y5zmycij774nnfyygshgju.wu4tdfz1d9w1pp55cjrf79wsdueykdqoeozccun3i58fa3okf7e69hemui9si1w.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:26,LUA_SUMMARY:none X-HE-Tag: hill12_0b1441226e81 X-Filterd-Recvd-Size: 4256 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Jul 2020 15:30:11 +0000 (UTC) IronPort-SDR: P1SPs7LQEZk902+mfq5XUxgnIGd4uiROU/E26S48oQAuA4oBBEv9rIb8/YIDTQP+mvO6eMYDpJ uSTNtK+2YKPw== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="134886195" X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="134886195" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2020 08:29:56 -0700 IronPort-SDR: ggTlTifZFGv2OXKF8Yqlnk+bQPFK3lXCuGnnGc9WyrL8+1SsPTKRvgsqtjtRoV9O6ePQ1ZObg1 UJRIopRh8r7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="265439405" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga007.fm.intel.com with ESMTP; 01 Jul 2020 08:29:55 -0700 Subject: [PATCH 2/3] mm/vmscan: move RECLAIM* bits to uapi header 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:24 -0700 References: <20200701152621.D520E62B@viggo.jf.intel.com> In-Reply-To: <20200701152621.D520E62B@viggo.jf.intel.com> Message-Id: <20200701152624.D6FBDDA8@viggo.jf.intel.com> X-Rspamd-Queue-Id: A165A6C2C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 It is currently not obvious that the RECLAIM_* bits are part of the uapi since they are defined in vmscan.c. Move them to a uapi header to make it obvious. 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 Acked-by: David Rientjes --- Note: This is not cc'd to stable. It does not fix any bugs. --- b/include/uapi/linux/mempolicy.h | 7 +++++++ b/mm/vmscan.c | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) diff -puN include/uapi/linux/mempolicy.h~mm-vmscan-move-RECLAIM-bits-to-uapi include/uapi/linux/mempolicy.h --- a/include/uapi/linux/mempolicy.h~mm-vmscan-move-RECLAIM-bits-to-uapi 2020-07-01 08:22:12.502955333 -0700 +++ b/include/uapi/linux/mempolicy.h 2020-07-01 08:22:12.508955333 -0700 @@ -62,5 +62,12 @@ enum { #define MPOL_F_MOF (1 << 3) /* this policy wants migrate on fault */ #define MPOL_F_MORON (1 << 4) /* Migrate On protnone Reference On Node */ +/* + * These bit locations are exposed in the vm.zone_reclaim_mode sysctl + * ABI. New bits are OK, but existing bits can never change. + */ +#define RECLAIM_ZONE (1<<0) /* Run shrink_inactive_list on the zone */ +#define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */ +#define RECLAIM_UNMAP (1<<2) /* Unmap pages during reclaim */ #endif /* _UAPI_LINUX_MEMPOLICY_H */ diff -puN mm/vmscan.c~mm-vmscan-move-RECLAIM-bits-to-uapi mm/vmscan.c --- a/mm/vmscan.c~mm-vmscan-move-RECLAIM-bits-to-uapi 2020-07-01 08:22:12.504955333 -0700 +++ b/mm/vmscan.c 2020-07-01 08:22:12.509955333 -0700 @@ -4091,14 +4091,6 @@ module_init(kswapd_init) int node_reclaim_mode __read_mostly; /* - * These bit locations are exposed in the vm.zone_reclaim_mode sysctl - * ABI. New bits are OK, but existing bits can never change. - */ -#define RECLAIM_ZONE (1<<0) /* Run shrink_inactive_list on the zone */ -#define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */ -#define RECLAIM_UNMAP (1<<2) /* Unmap pages during reclaim */ - -/* * Priority for NODE_RECLAIM. This determines the fraction of pages * of a node considered for each zone_reclaim. 4 scans 1/16th of * a zone. 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;