All of lore.kernel.org
 help / color / mirror / Atom feed
* Is stopmachine() preempt safe?
@ 2006-08-27  9:42 Keith Owens
  2006-08-27 23:38 ` Rusty Russell
  0 siblings, 1 reply; 6+ messages in thread
From: Keith Owens @ 2006-08-27  9:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: rusty, mingo

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?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-08-28  9:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2006-08-28  6:17     ` Rusty Russell
2006-08-28  6:36       ` Keith Owens
2006-08-28  9:21         ` Rusty Russell

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.