From: Keith Owens <kaos@ocs.com.au>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu
Subject: Re: Is stopmachine() preempt safe?
Date: Mon, 28 Aug 2006 12:55:18 +1000 [thread overview]
Message-ID: <16193.1156733718@ocs10w.ocs.com.au> (raw)
In-Reply-To: Your message of "Mon, 28 Aug 2006 09:38:55 +1000." <1156721935.10467.1.camel@localhost.localdomain>
Rusty Russell (on Mon, 28 Aug 2006 09:38:55 +1000) wrote:
>On Sun, 2006-08-27 at 19:42 +1000, Keith Owens wrote:
>> I cannot convince myself that stopmachine() is preempt safe. What
>> prevents this race with CONFIG_PREEMPT=y?
>
>Nothing. Read side is preempt_disable. Write side is stopmachine.
That is very worrying. The whole point of stopmachine is to get all
cpus to a known state with no locally cached global data, so the caller
of stopmachine can safely fiddle with some global data (like updating
the module lists). But CONFIG_PREEMPT defeats this and turns any code
that relies on stopmachine into a race.
What we need is either a scheduler flag or a new task state to be
assigned to the kstopmachine threads. That indicator says
If the current state is not preempt active then schedule me.
If the current state is preempt active then put me back in the active
queue.
While the runqueue contains at least one task with this flag then
ignore reschedule on irq and prempt_enable.
That will ensure that the kstopmachine threads get scheduled as soon as
possible but only when all the preempted tasks have got to a clean stop
point, e.g. sleep or yield. At which point they have no locally cached
global data, making stopmachine race safe again.
next prev parent reply other threads:[~2006-08-28 2:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-27 9:42 Is stopmachine() preempt safe? Keith Owens
2006-08-27 23:38 ` Rusty Russell
2006-08-28 2:55 ` Keith Owens [this message]
2006-08-28 6:17 ` Rusty Russell
2006-08-28 6:36 ` Keith Owens
2006-08-28 9:21 ` Rusty Russell
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=16193.1156733718@ocs10w.ocs.com.au \
--to=kaos@ocs.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
/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.