From: Keith Owens <kaos@ocs.com.au>
To: linux-kernel@vger.kernel.org
Cc: rusty@rustcorp.com.au, mingo@elte.hu
Subject: Is stopmachine() preempt safe?
Date: Sun, 27 Aug 2006 19:42:32 +1000 [thread overview]
Message-ID: <10990.1156671752@ocs10w.ocs.com.au> (raw)
I cannot convince myself that stopmachine() is preempt safe. What
prevents this race with CONFIG_PREEMPT=y?
cpu 0 cpu 1
stop_machine()
Process <n> reads a global resource
do_stop()
kernel_thread(stopmachine, 1)
Process <n> is preempted
stopmachine() runs on cpu 1
STOPMACHINE_PREPARE
STOPMACHINE_DISABLE_IRQ
do_stop() calls smdata->fn
smdata->fn changes global data
restart_machine()
STOPMACHINE_EXIT
stopmachine() exits
Scheduler resumes process <n>
The global resource is out of sync
The stopmachine() threads on the other cpus are set to MAX_RT_PRIO-1 so
they will preempt any existing process. The yield() in stopmachine()
only guarantees that these kernel threads get onto the other cpus, it
does not guarantee that all running tasks will proceed to a yield
themselves before stopmachine runs. IOW, what guarantees that the
scheduler will only run stopmachine() on the target cpus when those
cpus are completely idle with no locally cached global resources?
next reply other threads:[~2006-08-27 9:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-27 9:42 Keith Owens [this message]
2006-08-27 23:38 ` Is stopmachine() preempt safe? Rusty Russell
2006-08-28 2:55 ` Keith Owens
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=10990.1156671752@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.