path: root/ipc
diff options
authorManfred Spraul <>2009-12-15 16:47:31 -0800
committerLinus Torvalds <>2009-12-16 07:20:09 -0800
commitb6e90822e77cd476c18410f7003197d466e36ac6 (patch)
tree2ff18df8c024ae92e7e8912186c34b10b4b6f4bd /ipc
parentd4212093dca95c1f52197017d969cc66d5d962aa (diff)
ipc/sem.c: optimize if semops fail
Reduce the amount of scanning of the list of pending semaphore operations: If try_atomic_semop failed, then no changes were applied. Thus no need to restart. Additionally, this patch correct an incorrect comment: It's possible to wait for arbitrary semaphore values (do a dec by <x>, wait-for-zero, inc by <x> in one atomic operation) Both changes are from Nick Piggin, the patch is the result of a different split of the individual changes. Signed-off-by: Manfred Spraul <> Cc: Nick Piggin <> Cc: Pierre Peiffer <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'ipc')
1 files changed, 2 insertions, 2 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index 2705fbbc4374..eac3f46a5968 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -445,13 +445,13 @@ again:
* of the completed operation:
* - if the operation modified the array, then restart from the
* head of the queue and check for threads that might be
- * waiting for semaphore values to become 0.
+ * waiting for the new semaphore values.
* - if the operation didn't modify the array, then just
* continue.
alter = q->alter;
wake_up_sem_queue(q, error);
- if (alter)
+ if (alter && !error)
goto again;