From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933498AbcLBAPW (ORCPT ); Thu, 1 Dec 2016 19:15:22 -0500 Received: from terminus.zytor.com ([198.137.202.10]:55842 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932645AbcLBAPT (ORCPT ); Thu, 1 Dec 2016 19:15:19 -0500 Date: Thu, 1 Dec 2016 16:14:23 -0800 From: tip-bot for Anna-Maria Gleixner Message-ID: Cc: bigeasy@linutronix.de, anna-maria@linutronix.de, hpa@zytor.com, vbabka@suse.cz, mhocko@suse.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, mingo@kernel.org, mgorman@techsingularity.net, tglx@linutronix.de Reply-To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, hpa@zytor.com, anna-maria@linutronix.de, bigeasy@linutronix.de, tglx@linutronix.de, mgorman@techsingularity.net, mingo@kernel.org In-Reply-To: <20161126231350.10321-15-bigeasy@linutronix.de> References: <20161126231350.10321-15-bigeasy@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] mm/compaction: Convert to hotplug state machine Git-Commit-ID: e46b1db249d83bb19b6bdbed2b2e2ff3858cd211 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e46b1db249d83bb19b6bdbed2b2e2ff3858cd211 Gitweb: http://git.kernel.org/tip/e46b1db249d83bb19b6bdbed2b2e2ff3858cd211 Author: Anna-Maria Gleixner AuthorDate: Sun, 27 Nov 2016 00:13:42 +0100 Committer: Thomas Gleixner CommitDate: Fri, 2 Dec 2016 00:52:37 +0100 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 Signed-off-by: Sebastian Andrzej Siewior Cc: Michal Hocko Cc: Mel Gorman Cc: linux-mm@kvack.org Cc: rt@linutronix.de Cc: Andrew Morton Cc: Vlastimil Babka Link: http://lkml.kernel.org/r/20161126231350.10321-15-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner --- mm/compaction.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 0409a4a..0d37192 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2043,33 +2043,38 @@ void kcompactd_stop(int nid) * away, we get changed to run anywhere: as the first one comes back, * restore their cpu bindings. */ -static int cpu_callback(struct notifier_block *nfb, unsigned long action, - void *hcpu) +static int kcompactd_cpu_online(unsigned int cpu) { int nid; - if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) { - for_each_node_state(nid, N_MEMORY) { - pg_data_t *pgdat = NODE_DATA(nid); - const struct cpumask *mask; + for_each_node_state(nid, N_MEMORY) { + pg_data_t *pgdat = NODE_DATA(nid); + const struct cpumask *mask; - mask = cpumask_of_node(pgdat->node_id); + mask = cpumask_of_node(pgdat->node_id); - if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) - /* One of our CPUs online: restore mask */ - set_cpus_allowed_ptr(pgdat->kcompactd, mask); - } + if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) + /* One of our CPUs online: restore mask */ + set_cpus_allowed_ptr(pgdat->kcompactd, mask); } - return NOTIFY_OK; + return 0; } static int __init kcompactd_init(void) { 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) kcompactd_run(nid); - hotcpu_notifier(cpu_callback, 0); return 0; } subsys_initcall(kcompactd_init)