Commit dd2e3121 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar

stop_machine: Shift the 'done != NULL' check from cpu_stop_signal_done() to callers

Change cpu_stop_queue_work() and cpu_stopper_thread() to check done != NULL
before cpu_stop_signal_done(done). This makes the code more clean imo, note
that cpu_stopper_thread() has to do this check anyway.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Milos Vyletel <milos@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20151115193329.GA8274@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 6fa3b826
...@@ -64,10 +64,8 @@ static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo) ...@@ -64,10 +64,8 @@ static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
/* signal completion unless @done is NULL */ /* signal completion unless @done is NULL */
static void cpu_stop_signal_done(struct cpu_stop_done *done) static void cpu_stop_signal_done(struct cpu_stop_done *done)
{ {
if (done) { if (atomic_dec_and_test(&done->nr_todo))
if (atomic_dec_and_test(&done->nr_todo)) complete(&done->completion);
complete(&done->completion);
}
} }
static void __cpu_stop_queue_work(struct cpu_stopper *stopper, static void __cpu_stop_queue_work(struct cpu_stopper *stopper,
...@@ -88,7 +86,7 @@ static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work) ...@@ -88,7 +86,7 @@ static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work)
enabled = stopper->enabled; enabled = stopper->enabled;
if (enabled) if (enabled)
__cpu_stop_queue_work(stopper, work); __cpu_stop_queue_work(stopper, work);
else else if (work->done)
cpu_stop_signal_done(work->done); cpu_stop_signal_done(work->done);
spin_unlock_irqrestore(&stopper->lock, flags); spin_unlock_irqrestore(&stopper->lock, flags);
...@@ -457,12 +455,12 @@ static void cpu_stopper_thread(unsigned int cpu) ...@@ -457,12 +455,12 @@ static void cpu_stopper_thread(unsigned int cpu)
/* cpu stop callbacks are not allowed to sleep */ /* cpu stop callbacks are not allowed to sleep */
preempt_disable(); preempt_disable();
ret = fn(arg); ret = fn(arg);
if (ret && done) if (done) {
done->ret = ret; if (ret)
cpu_stop_signal_done(done); done->ret = ret;
cpu_stop_signal_done(done);
}
/* restore preemption and check it's still balanced */ /* restore preemption and check it's still balanced */
preempt_enable(); preempt_enable();
WARN_ONCE(preempt_count(), WARN_ONCE(preempt_count(),
......
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