Re: [RFC][PATCH 2/3] futex: Reduce hash bucket lock contention

From: Manfred Spraul
Date: Sat Sep 17 2011 - 08:51:24 EST


On 09/16/2011 02:34 PM, Peter Zijlstra wrote:
So while initially I thought the sem patch was busted, it turns out this
one is.

Thomas managed to spot the race:

Task-0 Task-1

futex_wait()
queue_me()

futex_wake()
wake_list_add();
__unqueue_futex();
plist_del();
if (!plist_node_empty())
__set_current_state(TASK_RUNNNIG);

wake_up_list();
/* waking an already running task-0 */


I guess the biggest question is, do we care? Ideally everything should
be able to deal with spurious wakeups, although we generally try to
avoid them.


The sem patch also causes such wakeups:

Task-0 Task-1
semtimedop()
schedule_timeout()

semtimedop()
wake_list_add();
q->status = 0;
<Timeout>
schedule_timeout() returns
if (q->status==0)
return;
semtimedop() returns

random user space/kernel space code

spin_unlock();
wake_up_list();

It's a rare event, but that does happen.
Which means:
How do we verify that everything is able to deal with spurious wakeups?

--
Manfred
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/