Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1445235ybv; Thu, 13 Feb 2020 23:34:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzyWKAEHMk/rMlqtFkuV9c2hurrPoLmXMTV0Tn+vcKWBKp50g5IKIhfbCmycogls9u/wNSY X-Received: by 2002:aca:cf52:: with SMTP id f79mr997359oig.129.1581665641795; Thu, 13 Feb 2020 23:34:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581665641; cv=none; d=google.com; s=arc-20160816; b=Xu63TYlYaQlEcih9GKyNJ15I6igiA7hEYsH37QVoEOySKkGvX0KaDuYFXiwv7mmtEa j3CIs1plTgxpVCVfwUZ6If0ip821BiGWz/EY67KbX81tNkWrwMKhwUSpcGIVTlNQ0g0/ f3e/TV0eI1bmy4/X9pAdh6OnUDqsmKtkLhh7VbgvLMDH093KSEWOAr5tzFr7Frfy/jvR RhTm8kdE8dc0aHnZRXzvsGlFAWaFThffVEdHUTerDJ1Kna9CblfiXnZIKK9uPH8+WSnX DKT0Rl6U+FM9qNdy/bqv7vq53FCxIwaBKz+72hdv3GzRssT3ky/jsWuB4xyF7aNBG559 y23w== 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=L+mH0AtVshHmGj6yowZczgHPbpRD5+9R0nA9KsvQ9Bk=; b=LBDjpJH5NQ9JS48m0LiQ7vblp4BNm1na8k2KIj9cpnEthjjOXioGSz7q4ICbZK6I6q BAtIgej49Ktt6raPiIs29H9cE9K/mwZYJnmMCHyiENNhz97EDM2Nhd9kjnM8IH+/xfe7 C3m8DIUoguq2xFJ0UxbqCtVZ1FGMENN5ABlFgY9srvsQFmxfxjTc74ZwBDLkMaCdyDjP 0i36WUSkeDD5vCE5fDpM8GJa/UsXLd9+HgcnOokYHqIpVl7BnRKcpUNyMXN6IE3/Z02K tLEjtcBQ6aomaI4A+hcdFoJNLpuWCm4SjvaDqDiC/WgX4snlLWc6oYZI8tl+l1usN0wf Ydjg== 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 m11si2316588oim.223.2020.02.13.23.33.48; Thu, 13 Feb 2020 23:34:01 -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 S1728841AbgBNHdP (ORCPT + 99 others); Fri, 14 Feb 2020 02:33:15 -0500 Received: from mga18.intel.com ([134.134.136.126]:29563 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728691AbgBNHdP (ORCPT ); Fri, 14 Feb 2020 02:33:15 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.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 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: 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; } -- 2.17.1