提交 b6e90822 编写于 作者: M Manfred Spraul 提交者: Linus Torvalds

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: NManfred Spraul <manfred@colorfullife.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Pierre Peiffer <peifferp@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d4212093
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册