Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2552184ybl; Sun, 26 Jan 2020 05:22:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwZj0bKdkFz/07ecBD1RJ3f4Sb/9c86FZyixrtVdVqx3SShWv518alxrHExuk6O9iqivmGI X-Received: by 2002:a05:6808:6d6:: with SMTP id m22mr4562139oih.138.1580044958394; Sun, 26 Jan 2020 05:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580044958; cv=none; d=google.com; s=arc-20160816; b=gE2k591PAzl1bjeH2XWQGQyp2f5I3hKPbscuVcw+ksJv4qXqRQwn61dtK9vSAIdWyA eBYndKonVH2PPMAEHx+cRqL7hrOho/AnxVqrfd0W5WM2L99gbd9Z2KnH/Hbr53tCpIR3 plcG6MjX9XLmnFSbUtSBqYhVJslR00Z1fxtMpPL+v5/TDb4aLUYJmprZnk5Ng9YFy65C sqtktWqhogNjavtYahqG67+cDIPJQfAUQhdYyv+T/0ZDG1gHCMNSpAyE5u072Jxm0HrF iGSw4WQp2HVMjpQpxLhilx5hGRm4v9k8q1hQWkkqinJjlE6VrIXfnIXcqGP+VRuMIoUj t2og== 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; bh=ICh+p2lwpaFlEOKYukgc4CVTmZuZusX/NCR2xPSCivs=; b=fYzIdEw4tfv+sYBGOAVmuQapdzEB7IiDZ06moDRi350zwsrDelzUrfC25Mw+k4xwli NOCiJnJuZn1spdsrFPw1tf56IBUU9kr/+JUViSEuS9nX1Dvc5KFdMvDBft50gcGASxWo XH4jU2hhLm28yIOO/L0tGA1F5xWMx5MiifFZ+OsaCIN2fBrZY2RK63NWXJK1xqeH4Lu4 a8gv7P7twOYPOeOK5HiH2NKWZh7Egjj/ry5M2vTetyMjUFCJdB4L3twnMIJUmAy0Izgs 9n3+OnpFHZCSG153w3wkmB0jYwTBq0XxulUeXP//DQxWFJM+6/MyB4cvd5MCPUxI/bag pWPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id k10si5749335otn.323.2020.01.26.05.22.26; Sun, 26 Jan 2020 05:22:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729099AbgAZNUp (ORCPT + 99 others); Sun, 26 Jan 2020 08:20:45 -0500 Received: from mga12.intel.com ([192.55.52.136]:1045 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726275AbgAZNUp (ORCPT ); Sun, 26 Jan 2020 08:20:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jan 2020 05:20:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,365,1574150400"; d="scan'208";a="401110421" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 26 Jan 2020 05:20:44 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH] mm/vmscan.c: only adjust related kswapd cpu affinity when online cpu Date: Sun, 26 Jan 2020 21:20:52 +0800 Message-Id: <20200126132052.11921-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When onlining a cpu, kswapd_cpu_online() is called to adjust kswapd cpu affinity. Current routine does like this: * Iterate all the numa node * Adjust cpu affinity when node has an online cpu Actually we could improve this by: * Just adjust the numa node to which current online cpu belongs Because we know which numa node the cpu belongs to and this cpu would not affect other node. 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 572fb17c6273..19c92d35045c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4049,18 +4049,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; } -- 2.17.1