Skip to content

Commit c6a566f

Browse files
author
Frederic Weisbecker
committed
mm: Create/affine kswapd to its preferred node
kswapd is dedicated to a specific node. As such it wants to be preferrably affine to it, memory and CPUs-wise. Use the proper kthread API to achieve that. As a bonus it takes care of CPU-hotplug events and CPU-isolation on its behalf. Acked-by: Vlastimil Babka <[email protected]> Acked-by: Michal Hocko <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 54880b5 commit c6a566f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

mm/vmscan.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7182,10 +7182,6 @@ static int kswapd(void *p)
71827182
unsigned int highest_zoneidx = MAX_NR_ZONES - 1;
71837183
pg_data_t *pgdat = (pg_data_t *)p;
71847184
struct task_struct *tsk = current;
7185-
const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id);
7186-
7187-
if (!cpumask_empty(cpumask))
7188-
set_cpus_allowed_ptr(tsk, cpumask);
71897185

71907186
/*
71917187
* Tell the memory management that we're a "memory allocator",
@@ -7354,13 +7350,15 @@ void __meminit kswapd_run(int nid)
73547350

73557351
pgdat_kswapd_lock(pgdat);
73567352
if (!pgdat->kswapd) {
7357-
pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
7353+
pgdat->kswapd = kthread_create_on_node(kswapd, pgdat, nid, "kswapd%d", nid);
73587354
if (IS_ERR(pgdat->kswapd)) {
73597355
/* failure at boot is fatal */
73607356
pr_err("Failed to start kswapd on node %d,ret=%ld\n",
73617357
nid, PTR_ERR(pgdat->kswapd));
73627358
BUG_ON(system_state < SYSTEM_RUNNING);
73637359
pgdat->kswapd = NULL;
7360+
} else {
7361+
wake_up_process(pgdat->kswapd);
73647362
}
73657363
}
73667364
pgdat_kswapd_unlock(pgdat);

0 commit comments

Comments
 (0)