[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200126132052.11921-1-richardw.yang@linux.intel.com>
Date: Sun, 26 Jan 2020 21:20:52 +0800
From: Wei Yang <richardw.yang@...ux.intel.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Wei Yang <richardw.yang@...ux.intel.com>
Subject: [PATCH] mm/vmscan.c: only adjust related kswapd cpu affinity when online cpu
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 <richardw.yang@...ux.intel.com>
---
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
Powered by blists - more mailing lists