Re: futex code and barriers

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Oleg Nesterov
Date: Tuesday, April 29, 2008 - 6:13 am

On 04/29, Peter Zijlstra wrote:

As for me, the comment is very confusing at least.


Not sure I understand this code, but probably it is correct.

Yes, add_wait_queue() is not a barrier, and both __set_current_state()
and the "!plist_node_empty()" check below can leak into the
add_wait_queue's critical section.

But wake_futex()->wake_up_all() has to lock/unlock the same q->lock,
so I think we can't miss the event.

IOW, when wake_futex()->wake_up_all() takes q->lock, it must see
TASK_INTERRUPTIBLE.

If wake_futex() takes q->lock before us, we must see the result
of plist_del() after add_wait_queue() (more precisely, after
add_wait_queue()->spin_lock(q->lock).

But I'd like to know maintainer's opinion, I don't trust myself ;)

Oleg.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
futex code and barriers, Peter Zijlstra, (Tue Apr 29, 4:57 am)
Re: futex code and barriers, Jiri Kosina, (Tue Apr 29, 5:43 am)
Re: futex code and barriers, Peter Zijlstra, (Tue Apr 29, 5:49 am)
Re: futex code and barriers, Oleg Nesterov, (Tue Apr 29, 6:13 am)