From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932214AbbHCRJ4 (ORCPT ); Mon, 3 Aug 2015 13:09:56 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40486 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932107AbbHCRJx (ORCPT ); Mon, 3 Aug 2015 13:09:53 -0400 Date: Mon, 3 Aug 2015 10:09:02 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: efault@gmx.de, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org, tj@kernel.org, tglx@linutronix.de, mingo@kernel.org, oleg@redhat.com, torvalds@linux-foundation.org Reply-To: torvalds@linux-foundation.org, oleg@redhat.com, tj@kernel.org, tglx@linutronix.de, mingo@kernel.org, efault@gmx.de, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org In-Reply-To: <20150630012948.GA23927@redhat.com> References: <20150630012948.GA23927@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] stop_machine: Don't do for_each_cpu() twice in queue_stop_cpus_work() Git-Commit-ID: b377c2a089d4538e6e62e51fa595c896c314d83d 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: b377c2a089d4538e6e62e51fa595c896c314d83d Gitweb: http://git.kernel.org/tip/b377c2a089d4538e6e62e51fa595c896c314d83d Author: Oleg Nesterov AuthorDate: Tue, 30 Jun 2015 03:29:48 +0200 Committer: Ingo Molnar CommitDate: Mon, 3 Aug 2015 12:21:26 +0200 stop_machine: Don't do for_each_cpu() twice in queue_stop_cpus_work() queue_stop_cpus_work() can do everything in one for_each_cpu() loop. Signed-off-by: Oleg Nesterov Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Tejun Heo Cc: Thomas Gleixner Cc: dave@stgolabs.net Cc: der.herr@hofr.at Cc: paulmck@linux.vnet.ibm.com Cc: riel@redhat.com Cc: viro@ZenIV.linux.org.uk Link: http://lkml.kernel.org/r/20150630012948.GA23927@redhat.com Signed-off-by: Ingo Molnar --- kernel/stop_machine.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 6e677b0..6212208 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -303,22 +303,19 @@ static void queue_stop_cpus_work(const struct cpumask *cpumask, struct cpu_stop_work *work; unsigned int cpu; - /* initialize works and done */ - for_each_cpu(cpu, cpumask) { - work = &per_cpu(cpu_stopper.stop_work, cpu); - work->fn = fn; - work->arg = arg; - work->done = done; - } - /* * Disable preemption while queueing to avoid getting * preempted by a stopper which might wait for other stoppers * to enter @fn which can lead to deadlock. */ lg_global_lock(&stop_cpus_lock); - for_each_cpu(cpu, cpumask) - cpu_stop_queue_work(cpu, &per_cpu(cpu_stopper.stop_work, cpu)); + for_each_cpu(cpu, cpumask) { + work = &per_cpu(cpu_stopper.stop_work, cpu); + work->fn = fn; + work->arg = arg; + work->done = done; + cpu_stop_queue_work(cpu, work); + } lg_global_unlock(&stop_cpus_lock); }