diff options
author | Cheng Chao | 2016-09-14 04:01:50 +0200 |
---|---|---|
committer | Ingo Molnar | 2016-09-22 14:53:45 +0200 |
commit | bf89a304722f6904009499a31dc68ab9a5c9742e (patch) | |
tree | 2177d0136fa62ca04091b6f5823ad32b055bbf7c /kernel/stop_machine.c | |
parent | sched/core: Remove unnecessary initialization in sched_init() (diff) | |
download | kernel-qcow2-linux-bf89a304722f6904009499a31dc68ab9a5c9742e.tar.gz kernel-qcow2-linux-bf89a304722f6904009499a31dc68ab9a5c9742e.tar.xz kernel-qcow2-linux-bf89a304722f6904009499a31dc68ab9a5c9742e.zip |
stop_machine: Avoid a sleep and wakeup in stop_one_cpu()
In case @cpu == smp_proccessor_id(), we can avoid a sleep+wakeup
cycle by doing a preemption.
Callers such as sched_exec() can benefit from this change.
Signed-off-by: Cheng Chao <cs.os.kernel@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: akpm@linux-foundation.org
Cc: chris@chris-wilson.co.uk
Cc: tj@kernel.org
Link: http://lkml.kernel.org/r/1473818510-6779-1-git-send-email-cs.os.kernel@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/stop_machine.c')
-rw-r--r-- | kernel/stop_machine.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 4a1ca5f6da7e..082e71f17a58 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -126,6 +126,11 @@ int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg) cpu_stop_init_done(&done, 1); if (!cpu_stop_queue_work(cpu, &work)) return -ENOENT; + /* + * In case @cpu == smp_proccessor_id() we can avoid a sleep+wakeup + * cycle by doing a preemption: + */ + cond_resched(); wait_for_completion(&done.completion); return done.ret; } |