From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753765AbbKWQYQ (ORCPT ); Mon, 23 Nov 2015 11:24:16 -0500 Received: from terminus.zytor.com ([198.137.202.10]:44502 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751855AbbKWQYM (ORCPT ); Mon, 23 Nov 2015 11:24:12 -0500 Date: Mon, 23 Nov 2015 08:23:31 -0800 From: tip-bot for Oleg Nesterov Message-ID: Cc: tj@kernel.org, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, torvalds@linux-foundation.org, milos@redhat.com, efault@gmx.de, hpa@zytor.com, oleg@redhat.com, prarit@redhat.com, linux-kernel@vger.kernel.org Reply-To: prarit@redhat.com, linux-kernel@vger.kernel.org, oleg@redhat.com, hpa@zytor.com, efault@gmx.de, mingo@kernel.org, torvalds@linux-foundation.org, milos@redhat.com, peterz@infradead.org, tj@kernel.org, tglx@linutronix.de In-Reply-To: <20151115193329.GA8274@redhat.com> References: <20151115193329.GA8274@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] stop_machine: Shift the 'done != NULL' check from cpu_stop_signal_done() to callers Git-Commit-ID: dd2e3121e3cb16d03a6e3f2db48f260f046f39c2 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: dd2e3121e3cb16d03a6e3f2db48f260f046f39c2 Gitweb: http://git.kernel.org/tip/dd2e3121e3cb16d03a6e3f2db48f260f046f39c2 Author: Oleg Nesterov AuthorDate: Sun, 15 Nov 2015 20:33:29 +0100 Committer: Ingo Molnar CommitDate: Mon, 23 Nov 2015 09:48:19 +0100 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: Oleg Nesterov Signed-off-by: Peter Zijlstra (Intel) Acked-by: Tejun Heo Cc: Linus Torvalds Cc: Mike Galbraith Cc: Milos Vyletel Cc: Peter Zijlstra Cc: Prarit Bhargava Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20151115193329.GA8274@redhat.com Signed-off-by: Ingo Molnar --- kernel/stop_machine.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 09eb83f..7ff7ace 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -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 */ static void cpu_stop_signal_done(struct cpu_stop_done *done) { - if (done) { - if (atomic_dec_and_test(&done->nr_todo)) - complete(&done->completion); - } + if (atomic_dec_and_test(&done->nr_todo)) + complete(&done->completion); } 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) enabled = stopper->enabled; if (enabled) __cpu_stop_queue_work(stopper, work); - else + else if (work->done) cpu_stop_signal_done(work->done); spin_unlock_irqrestore(&stopper->lock, flags); @@ -457,12 +455,12 @@ repeat: /* cpu stop callbacks are not allowed to sleep */ preempt_disable(); - ret = fn(arg); - if (ret && done) - done->ret = ret; - cpu_stop_signal_done(done); - + if (done) { + if (ret) + done->ret = ret; + cpu_stop_signal_done(done); + } /* restore preemption and check it's still balanced */ preempt_enable(); WARN_ONCE(preempt_count(),