From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933933AbbGUTYa (ORCPT ); Tue, 21 Jul 2015 15:24:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46137 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933377AbbGUTY3 (ORCPT ); Tue, 21 Jul 2015 15:24:29 -0400 Date: Tue, 21 Jul 2015 21:22:38 +0200 From: Oleg Nesterov To: Ingo Molnar Cc: Peter Zijlstra , Rik van Riel , Tejun Heo , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] stop_machine: don't do for_each_cpu() twice in queue_stop_cpus_work() Message-ID: <20150721192238.GA31174@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150721192219.GA31150@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org queue_stop_cpus_work() can do everything in one for_each_cpu() loop. Signed-off-by: Oleg Nesterov --- kernel/stop_machine.c | 17 +++++++---------- 1 files 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); } -- 1.7.1