On Thu, 2011-09-15 at 21:35 +0200, Peter Zijlstra wrote:Correct. Just think about a timeout of semtimedop().On Thu, 2011-09-15 at 21:32 +0200, Peter Zijlstra wrote:Ah, but if the wakeup happens early, we return from schedule with -EINTROK, I can't read properly.. so the problem with doing the+static void wake_up_sem_queue_prepare(struct wake_list_head *wake_list,I think the get_task_struct()/put_task_struct is not necessary:
struct sem_queue *q, int error)
{
+ struct task_struct *p = ACCESS_ONCE(q->sleeper);
+ get_task_struct(p);
+ q->status = error;
+ /*
+ * implies a full barrier
+ */
+ wake_list_add(wake_list, p);
+ put_task_struct(p);
}
Just do the wake_list_add() before writing q->status:
wake_list_add() is identical to list_add_tail(&q->simple_list, pt).
[except that it contains additional locking, which doesn't matter here]
wake_list_add() before the write is that the wakeup can actually happen
before the write in case p already had a wakeup queued.
and re-acquire the sem_lock and re-test. Since we do this update from
under sem_lock it should serialize and come out all-right,.. right?