lkml.org 
[lkml]   [2013]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] wait-simple: Introduce the simple waitqueue implementation
On Thu, Dec 12, 2013 at 12:10:15PM -0500, Steven Rostedt wrote:
> So if we break up your code above, we have:
>
> raw_spin_lock_irqsave(&head->lock, flags);
> w->task = current;
> if (list_empty(&w->node)) {
> list_add(&w->node, &head->list);
> smp_mb();
> }
> __set_current_state(state);
> raw_spin_unlock_irqrestore(&head->lock, flags);
>
> if (!cond)
> schedule();
>

the unlock is semi-permeable and would allow the cond test to cross over
and even be satisfied before the state write.

>
> vs
>
> cond = true;
>
> raw_spin_lock_irqsave(&head->lock, flags);
> woken = __swait_wake_locked(head, state, num);
> raw_spin_unlock_irqrestore(&head->lock, flags);

Same here, the lock is semi-permeable and would allow the cond store to
leak down.

In the first case we really need the implied mb of set_current_state(),
the the second case the actual wakeup would still provide the required
barrier.


\
 
 \ /
  Last update: 2013-12-12 18:41    [W:0.143 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site