lkml.org 
[lkml]   [2009]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] It may not be assumed that wake_up(), finish_wait() and co. imply a memory barrier
On 04/24, David Howells wrote:
>
> (2) wake_up() interpolates a write memory barrier before clearing the task
> state - _if_ it wakes anything up - then there's no problem in the waker
> either.
>
[...snip...]
>
> +A write memory barrier is implied by wake_up() and co. if and only if they wake
> +something up. The barrier occurs before the task state is cleared, and so sits
> +between the STORE to indicate the event and the STORE to set TASK_RUNNING:

Very minor nit. Perhaps it makes sense to mention that we also need the
barrier before _reading_ the task->state as well. Or not, I am not sure ;)
Just in case...

event_indicated = 1;
wake_up_process(event_daemon);

Suppose that "event_indicated = 1" leaks into try_to_wake_up() after we
read p->state. In this case we have

try_to_wake_up:

if (!(p->state & state))
goto out; // do nothing
// WINDOW
event_indicated = 1; // leaked
In that case the whole

set_current_state(TASK_UNINTERRUPTIBLE);
if (event_indicated)
break;
schedule();
can happen in the WINDOW above.

But again, this is the real nitpick, and probably just the "implementation
details" which should not be documented.

Oleg.



\
 
 \ /
  Last update: 2009-04-24 19:37    [from the cache]
©2003-2011 Jasper Spaans