Skip to content

Commit

Permalink
ipc/sem.c: optimize if semops fail
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Pierre Peiffer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
manfred-colorfu authored and torvalds committed Dec 16, 2009
1 parent d421209 commit b6e9082
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,13 @@ static void update_queue (struct sem_array * sma)
* 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;
}
}
Expand Down

0 comments on commit b6e9082

Please sign in to comment.