lkml.org 
[lkml]   [2016]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Memory barrier needed with wake_up_process()?
On Fri, Sep 02, 2016 at 04:29:19PM -0400, Alan Stern wrote:
> I'm afraid so. The code doesn't use wait_event(), in part because
> there's no wait_queue (since only one task is involved).

You can use wait_queue fine with just one task, and it would clean up
the code tremendously.

You can replace things like the earlier mentioned:

while (bh->state != BUF_STATE_EMPTY) {
rc = sleep_thread(common, false);
if (rc)
return rc;
}

with:

rc = wait_event_interruptible(&common->wq, bh->state == BUF_STATE_EMPTY);
if (rc)
return rc;

> But maybe there's another barrier which needs to be fixed. Felipe, can
> you check to see if received_cbw() is getting called in
> get_next_command(), and if so, what value it returns? Or is the
> preceding sleep_thread() the one that never wakes up?
>
> It could be that the smp_wmb() in wakeup_thread() needs to be smp_mb().
> The reason being that get_next_command() runs outside the protection of
> the spinlock.

Being somewhat confused by the code, I fail to follow that argument.
wakeup_thread() is always called under that spinlock(), but since the
critical section is 2 stores, I fail to see how a smp_mb() can make any
difference over the smp_wmb() already there.

\
 
 \ /
  Last update: 2016-09-17 09:58    [W:0.066 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site