From: Manfred Spraul Date: Wed, 2 Nov 2011 20:38:52 +0000 (-0700) Subject: ipc/sem.c: handle spurious wakeups X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0b0577f6080c0645b079dcc03fdbaf40d928beb8;p=openwrt%2Fstaging%2Fblogic.git 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 Reported-by: Peter Zijlstra Acked-by: Peter Zijlstra Cc: Thomas Gleixner Cc: Mike Galbraith Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/ipc/sem.c b/ipc/sem.c index fb13be17945b..227948f28ce6 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -1426,6 +1426,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, queue.status = -EINTR; queue.sleeper = current; + +sleep_again: current->state = TASK_INTERRUPTIBLE; sem_unlock(sma); @@ -1478,6 +1480,13 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, */ if (timeout && jiffies_left == 0) error = -EAGAIN; + + /* + * If the wakeup was spurious, just retry + */ + if (error == -EINTR && !signal_pending(current)) + goto sleep_again; + unlink_queue(sma, &queue); out_unlock_free: