summaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorAnna-Maria Gleixner <anna-maria@linutronix.de>2016-11-26 18:13:42 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-12-01 18:52:37 -0500
commite46b1db249d83bb19b6bdbed2b2e2ff3858cd211 (patch)
tree76cbcfff1eb753032cd3f57e1bbbd4e75773eca0 /mm/compaction.c
parent21647615db288d9dacad0de6a5df846b39d51bea (diff)
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: Anna-Maria Gleixner <anna-maria@linutronix.de> Signed-off-by: Sebastian 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.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index 0409a4ad6ea1..0d37192d9423 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2043,33 +2043,38 @@ void kcompactd_stop(int nid)
2043 * away, we get changed to run anywhere: as the first one comes back, 2043 * away, we get changed to run anywhere: as the first one comes back,
2044 * restore their cpu bindings. 2044 * restore their cpu bindings.
2045 */ 2045 */
2046static int cpu_callback(struct notifier_block *nfb, unsigned long action, 2046static int kcompactd_cpu_online(unsigned int cpu)
2047 void *hcpu)
2048{ 2047{
2049 int nid; 2048 int nid;
2050 2049
2051 if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) { 2050 for_each_node_state(nid, N_MEMORY) {
2052 for_each_node_state(nid, N_MEMORY) { 2051 pg_data_t *pgdat = NODE_DATA(nid);
2053 pg_data_t *pgdat = NODE_DATA(nid); 2052 const struct cpumask *mask;
2054 const struct cpumask *mask;
2055 2053
2056 mask = cpumask_of_node(pgdat->node_id); 2054 mask = cpumask_of_node(pgdat->node_id);
2057 2055
2058 if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) 2056 if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids)
2059 /* One of our CPUs online: restore mask */ 2057 /* One of our CPUs online: restore mask */
2060 set_cpus_allowed_ptr(pgdat->kcompactd, mask); 2058 set_cpus_allowed_ptr(pgdat->kcompactd, mask);
2061 }
2062 } 2059 }
2063 return NOTIFY_OK; 2060 return 0;
2064} 2061}
2065 2062
2066static int __init kcompactd_init(void) 2063static int __init kcompactd_init(void)
2067{ 2064{
2068 int nid; 2065 int nid;
2066 int ret;
2067
2068 ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
2069 "mm/compaction:online",
2070 kcompactd_cpu_online, NULL);
2071 if (ret < 0) {
2072 pr_err("kcompactd: failed to register hotplug callbacks.\n");
2073 return ret;
2074 }
2069 2075
2070 for_each_node_state(nid, N_MEMORY) 2076 for_each_node_state(nid, N_MEMORY)
2071 kcompactd_run(nid); 2077 kcompactd_run(nid);
2072 hotcpu_notifier(cpu_callback, 0);
2073 return 0; 2078 return 0;
2074} 2079}
2075subsys_initcall(kcompactd_init) 2080subsys_initcall(kcompactd_init)