On Fri, Aug 11, 2017 at 11:14:34AM +0200, Peter Zijlstra wrote:
> On Thu, Aug 10, 2017 at 09:54:53PM -0700, Paul E. McKenney wrote:
> > On Fri, Aug 11, 2017 at 02:43:52PM +1000, Stephen Rothwell wrote:
> > Looks like I need to rebase my patch on top of a9668cd6ee28, and
> > than put an smp_mb__after_spinlock() between the lock and the unlock.
> > Peter, any objections to that approach? Other suggestions?
> Hurm.. I'll have to try and understand that comment there again it
OK, so per commit b5740f4b2cb3 ("sched: Fix ancient race in do_exit()")
the race is with try_to_wake_up():
p->state = TASK_UNINTERRUPTIBLE;
/* check stuff, no need to schedule() */
p->state = TASK_RUNNING
p->state = TASK_DEAD
TASK_RUNNING /* whoops! */
So given that, I think that:
current->state = TASK_DEAD;
is sufficient. I don't see a need for an additional smp_mb here.
Either the concurrent ttwu is finished and we must observe its RUNNING
store, or it will observe our RUNNING store.