Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipc/sem.c: handle spurious wakeups

semtimedop() does not handle spurious wakeups, it returns -EINTR to user
space. Most other schedule() users would just loop and not return to user
space. The patch adds such a loop to semtimedop()

Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Reported-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Galbraith <efault@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Manfred Spraul and committed by
Linus Torvalds
0b0577f6 3c24783b

+9
+9
ipc/sem.c
··· 1426 1426 1427 1427 queue.status = -EINTR; 1428 1428 queue.sleeper = current; 1429 + 1430 + sleep_again: 1429 1431 current->state = TASK_INTERRUPTIBLE; 1430 1432 sem_unlock(sma); 1431 1433 ··· 1480 1478 */ 1481 1479 if (timeout && jiffies_left == 0) 1482 1480 error = -EAGAIN; 1481 + 1482 + /* 1483 + * If the wakeup was spurious, just retry 1484 + */ 1485 + if (error == -EINTR && !signal_pending(current)) 1486 + goto sleep_again; 1487 + 1483 1488 unlink_queue(sma, &queue); 1484 1489 1485 1490 out_unlock_free: