summaryrefslogtreecommitdiffstats
path: root/kernel/stop_machine.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2017-05-24 04:15:16 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-05-26 04:10:36 -0400
commitfe5595c074005bd94f0c7d1644175941149f6768 (patch)
treedbdc36f344ab77ec7d2624687ae46fc787059b46 /kernel/stop_machine.c
parent9805c6733349ea3ccd22cf75b8ebaabb5290e310 (diff)
stop_machine: Provide stop_machine_cpuslocked()
Some call sites of stop_machine() are within a get_online_cpus() protected region. stop_machine() calls get_online_cpus() as well, which is possible in the current implementation but prevents converting the hotplug locking to a percpu rwsem. Provide stop_machine_cpuslocked() to avoid nested calls to get_online_cpus(). Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/20170524081547.400700852@linutronix.de
Diffstat (limited to 'kernel/stop_machine.c')
-rw-r--r--kernel/stop_machine.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 1eb82661ecdb..b7591261652d 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -552,7 +552,8 @@ static int __init cpu_stop_init(void)
552} 552}
553early_initcall(cpu_stop_init); 553early_initcall(cpu_stop_init);
554 554
555static int __stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) 555int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data,
556 const struct cpumask *cpus)
556{ 557{
557 struct multi_stop_data msdata = { 558 struct multi_stop_data msdata = {
558 .fn = fn, 559 .fn = fn,
@@ -561,6 +562,8 @@ static int __stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cp
561 .active_cpus = cpus, 562 .active_cpus = cpus,
562 }; 563 };
563 564
565 lockdep_assert_cpus_held();
566
564 if (!stop_machine_initialized) { 567 if (!stop_machine_initialized) {
565 /* 568 /*
566 * Handle the case where stop_machine() is called 569 * Handle the case where stop_machine() is called
@@ -590,9 +593,9 @@ int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
590 int ret; 593 int ret;
591 594
592 /* No CPUs can come up or down during this. */ 595 /* No CPUs can come up or down during this. */
593 get_online_cpus(); 596 cpus_read_lock();
594 ret = __stop_machine(fn, data, cpus); 597 ret = stop_machine_cpuslocked(fn, data, cpus);
595 put_online_cpus(); 598 cpus_read_unlock();
596 return ret; 599 return ret;
597} 600}
598EXPORT_SYMBOL_GPL(stop_machine); 601EXPORT_SYMBOL_GPL(stop_machine);