From patchwork Fri Feb 14 07:33:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11381823 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 8DC7D13A4 for ; Fri, 14 Feb 2020 07:33:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B11924649 for ; Fri, 14 Feb 2020 07:33:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B11924649 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 88C346B0602; Fri, 14 Feb 2020 02:33:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 83C736B0603; Fri, 14 Feb 2020 02:33:17 -0500 (EST) 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 753436B0604; Fri, 14 Feb 2020 02:33:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 5BFE56B0602 for ; Fri, 14 Feb 2020 02:33:17 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D0CA12825 for ; Fri, 14 Feb 2020 07:33:16 +0000 (UTC) X-FDA: 76487916792.05.earth67_56c61178a442c X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,richardw.yang@linux.intel.com,:akpm@linux-foundation.org::linux-kernel@vger.kernel.org:rientjes@google.com:richardw.yang@linux.intel.com,RULES_HIT:30054:30069:30070,0,RBL:134.134.136.31:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: earth67_56c61178a442c X-Filterd-Recvd-Size: 2978 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Feb 2020 07:33:16 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 23:33:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,439,1574150400"; d="scan'208";a="257438882" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga004.fm.intel.com with ESMTP; 13 Feb 2020 23:33:13 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, rientjes@google.com, Wei Yang Subject: [PATCH v2] mm/vmscan.c: only adjust related kswapd cpu affinity when online cpu Date: Fri, 14 Feb 2020 15:33:20 +0800 Message-Id: <20200214073320.28735-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 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: When onlining a cpu, kswapd_cpu_online() is called to adjust kswapd cpu affinity. Current routine does like this: a) Iterate all the numa node b) Adjust cpu affinity when node has an online cpu For a) this is not necessary, since the particular online cpu belongs to a particular numa node. So it is not necessary to iterate on every nodes on the system. This new onlined cpu just affect kswapd cpu affinity of this particular node. For b) several cpumask operation is used to check whether the node has an online CPU. Since at this point we are sure one of our CPU onlined, we can set the cpu affinity directly to current cpumask_of_node(). This patch simplifies the logic by set cpu affinity of the affected kswapd. --- v2: * rephrase the changelog Signed-off-by: Wei Yang --- mm/vmscan.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 665f33258cd7..acc5af82b6ed 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4029,18 +4029,19 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) restore their cpu bindings. */ static int kswapd_cpu_online(unsigned int cpu) { - int nid; + int nid = cpu_to_node(cpu); + pg_data_t *pgdat; + const struct cpumask *mask; - for_each_node_state(nid, N_MEMORY) { - pg_data_t *pgdat = NODE_DATA(nid); - const struct cpumask *mask; + if (!node_state(nid, N_MEMORY)) + return 0; - mask = cpumask_of_node(pgdat->node_id); + pgdat = NODE_DATA(nid); + mask = cpumask_of_node(nid); + + /* One of our CPUs online: restore mask */ + set_cpus_allowed_ptr(pgdat->kswapd, mask); - if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) - /* One of our CPUs online: restore mask */ - set_cpus_allowed_ptr(pgdat->kswapd, mask); - } return 0; }