lkml.org 
[lkml]   [2008]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC,PATCH] workqueues: turn queue_work() into the "barrier" for work->func()
On 11/11, David Howells wrote:
>
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > I think the caller of queue_work() has all rights to expect that
> > the next invocation of work_func() must see "VAR == 1", but this
> > is not true if the work is already pending.
>
> As you said, queue_work() does test_and_set_bit() which implies smp_mb()
> either side of the function, so you're half way there, and run_workqueue()
> calls spin_unlock_irq() just before calling work_clear_pending()... So might
> it make sense to move the work_clear_pending() into locked section? Or would
> that require an smp_mb__before_clear_bit()?

This can't really help, afaics. We still need mb() between clear_bit(_PENDING)
and LOAD(VAR). Because unlock() is the "one way" barrier, LOAD(VAR) can leak
into the critical section, and it can be re-ordered with clear_bit() inside
the critical section.

Oleg.



\
 
 \ /
  Last update: 2008-11-12 12:01    [W:0.068 / U:0.684 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site