From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH RFC] stop_machine: make stop_machine safe and efficient to call early
Date: Fri, 30 Sep 2011 16:32:40 -0700 [thread overview]
Message-ID: <4E865198.1070901@goop.org> (raw)
In-Reply-To: <20110930230635.GA2658@mtj.dyndns.org>
On 09/30/2011 04:06 PM, Tejun Heo wrote:
> Hello, Jeremy.
>
> On Fri, Sep 30, 2011 at 09:28:15AM -0700, Jeremy Fitzhardinge wrote:
>> Make stop_machine() safe to call early in boot, before SMP has been
>> set up, by simply calling the callback function directly if there's
>> only one CPU online.
> ...
>> @@ -485,6 +485,9 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
>> .num_threads = num_online_cpus(),
>> .active_cpus = cpus };
>>
>> + if (smdata.num_threads == 1)
>> + return (*fn)(data);
>> +
> As others have pointed out, you'll need to call both local and hardirq
> disables. Also, I think the description and the code are a bit
> misleading. How aobut setting cpu_stop_initialized in cpu_stop_init()
> and testing it from __stop_machine() instead? I think it would be
> better to keep the behavior as uniform as possible once things are up
> and running.
Yes, I was wondering about that. Do you think the patch (with irq fixes
in place) would affect the behaviour of an SMP kernel running UP?
J
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index f5855fe3..70b3be4 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -41,6 +41,7 @@ struct cpu_stopper {
};
static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper);
+static bool stop_machine_initialized = false;
static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
{
@@ -386,6 +387,8 @@ static int __init cpu_stop_init(void)
cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu);
register_cpu_notifier(&cpu_stop_cpu_notifier);
+ stop_machine_initialized = true;
+
return 0;
}
early_initcall(cpu_stop_init);
@@ -485,7 +488,7 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
.num_threads = num_online_cpus(),
.active_cpus = cpus };
- if (smdata.num_threads == 1) {
+ if (!stop_machine_initialized) {
/*
* Handle the case where stop_machine() is called early in boot
* before SMP startup.
next prev parent reply other threads:[~2011-09-30 23:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-30 16:28 [PATCH RFC] stop_machine: make stop_machine safe and efficient to call early Jeremy Fitzhardinge
2011-09-30 16:34 ` Steven Rostedt
2011-09-30 17:00 ` Jeremy Fitzhardinge
2011-09-30 21:06 ` Andrew Morton
2011-09-30 21:21 ` Steven Rostedt
2011-09-30 21:23 ` Andrew Morton
2011-09-30 23:06 ` Tejun Heo
2011-09-30 23:32 ` Jeremy Fitzhardinge [this message]
2011-09-30 23:39 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E865198.1070901@goop.org \
--to=jeremy@goop.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.