lkml.org 
[lkml]   [2008]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: + poll-allow-f_op-poll-to-sleep-take-4.patch added to -mm tree
Hello,

Oleg Nesterov wrote:
> So, why do we need this mb() in pollwake() ?
>
> try_to_wake_up() has a full barrier semantics, note the wmb() before
> task_rq_lock(). Since spin_lock() itself is STORE, the setting of
> pwq->triggered can't be further re-ordered with the reading of p->state.
>
> Or any other reason ?

try_to_wake_up() is a full barrier. Is it something guaranteed and
intentional or is it just something which just happened to be so?
Also, as the function is doing some dirty hackery to get to
try_to_wake_up(), I just wanted to make it clear. I suppose it's time
to add more comments there then.

>> + /* clear triggered for the next iteration */
>> + pwq->triggered = 0;
>
> And don't we (in theory) actually need the mb() here instead?
>
> Let's suppose do_poll() starts the next iteration, so we are doing
>
> pwq->triggered = 0;
>
> ->poll(file)
> if (!check_file(file))
> return 0;
>
> return POLLXXX;
>
> We don't have any barriers in between (unless fget_light bumps
> ->f_count), so this can be reordered as
>
> ->poll(file)
> if (!check_file(file))
> return 0;
>
> pwq->triggered = 0;
>
> And, if pollwake() happens in between we can miss the event, no?

Hmmmm... yes, from the second run, ->poll doesn't grab the waitqueue
lock, so it doesn't necessary have the required barriers.
Heh... set_mb() should be here not in pollwake(). Thanks for spotting
it.
--
tejun


\
 
 \ /
  Last update: 2008-11-26 05:37    [from the cache]
©2003-2011 Jasper Spaans