* [PATCH 2/5] ipc/sem.c: handle spurious wakeups
@ 2011-10-15 13:21 Manfred Spraul
0 siblings, 0 replies; only message in thread
From: Manfred Spraul @ 2011-10-15 13:21 UTC (permalink / raw)
To: LKML, Andrew Morton
Cc: Thomas Gleixner, Mike Galbraith, Peter Zijlstra, Manfred Spraul
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()
Reported-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
---
ipc/sem.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ipc/sem.c b/ipc/sem.c
index fb13be1..227948f 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:
--
1.7.6
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-15 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-15 13:21 [PATCH 2/5] ipc/sem.c: handle spurious wakeups Manfred Spraul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®