Messages in this thread | | | From | Linus Torvalds <> | Date | Wed, 4 May 2011 20:53:39 -0700 | Subject | Re: [PATCH] trace: Check for waiting readers before calling wakeup() |
| |
On Wed, May 4, 2011 at 2:26 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote: > On Wed, May 04, 2011 at 02:21:28PM -0700, Vaibhav Nagarnaik wrote: >> Steven, Frederic >> >> Does this patch look ok? >> >> Vaibhav Nagarnaik >> > > No problem for me. I'll let Steve give the last word.
Almost every time somebody does this optimization, there's a race.
The thing is, because waitqueue_active() implies no barriers, if there is somebody adding itself to the waitqueue just at the same time as somebody is waking things up, the waiter may lose wakeup events - there is no memory barriers to guarantee that the waker will see either the waiter, or the waiter will see the event that it waited for.
I dunno. It's sometimes safe, but it's equally often not safe unless there is some other locking around the thing. So I'd be a bit nervous. The tracer people would need to do some serious thinking about it.
Linus
| |