Commit e46b1db2 authored by Anna-Maria Gleixner's avatar Anna-Maria Gleixner Committed by Thomas Gleixner

mm/compaction: Convert to hotplug state machine

Install the callbacks via the state machine. Should the hotplug init fail then
no threads are spawned.
Signed-off-by: default avatarAnna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: linux-mm@kvack.org
Cc: rt@linutronix.de
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Link: http://lkml.kernel.org/r/20161126231350.10321-15-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 21647615
...@@ -2043,12 +2043,10 @@ void kcompactd_stop(int nid) ...@@ -2043,12 +2043,10 @@ void kcompactd_stop(int nid)
* away, we get changed to run anywhere: as the first one comes back, * away, we get changed to run anywhere: as the first one comes back,
* restore their cpu bindings. * restore their cpu bindings.
*/ */
static int cpu_callback(struct notifier_block *nfb, unsigned long action, static int kcompactd_cpu_online(unsigned int cpu)
void *hcpu)
{ {
int nid; int nid;
if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) {
for_each_node_state(nid, N_MEMORY) { for_each_node_state(nid, N_MEMORY) {
pg_data_t *pgdat = NODE_DATA(nid); pg_data_t *pgdat = NODE_DATA(nid);
const struct cpumask *mask; const struct cpumask *mask;
...@@ -2059,17 +2057,24 @@ static int cpu_callback(struct notifier_block *nfb, unsigned long action, ...@@ -2059,17 +2057,24 @@ static int cpu_callback(struct notifier_block *nfb, unsigned long action,
/* One of our CPUs online: restore mask */ /* One of our CPUs online: restore mask */
set_cpus_allowed_ptr(pgdat->kcompactd, mask); set_cpus_allowed_ptr(pgdat->kcompactd, mask);
} }
} return 0;
return NOTIFY_OK;
} }
static int __init kcompactd_init(void) static int __init kcompactd_init(void)
{ {
int nid; int nid;
int ret;
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
"mm/compaction:online",
kcompactd_cpu_online, NULL);
if (ret < 0) {
pr_err("kcompactd: failed to register hotplug callbacks.\n");
return ret;
}
for_each_node_state(nid, N_MEMORY) for_each_node_state(nid, N_MEMORY)
kcompactd_run(nid); kcompactd_run(nid);
hotcpu_notifier(cpu_callback, 0);
return 0; return 0;
} }
subsys_initcall(kcompactd_init) subsys_initcall(kcompactd_init)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment