ipc/sem: use proper list api for pending_list wakeups

... saves some LoC and looks cleaner than re-implementing the calls.

Link: http://lkml.kernel.org/r/1474225896-10066-6-git-send-email-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Davidlohr Bueso 2016-12-14 15:06:43 -08:00 committed by Linus Torvalds
parent 4663d3e8f2
commit f150f02cfb
1 changed files with 13 additions and 25 deletions

View File

@ -813,8 +813,7 @@ static inline int check_restart(struct sem_array *sma, struct sem_queue *q)
static int wake_const_ops(struct sem_array *sma, int semnum, static int wake_const_ops(struct sem_array *sma, int semnum,
struct wake_q_head *wake_q) struct wake_q_head *wake_q)
{ {
struct sem_queue *q; struct sem_queue *q, *tmp;
struct list_head *walk;
struct list_head *pending_list; struct list_head *pending_list;
int semop_completed = 0; int semop_completed = 0;
@ -823,25 +822,19 @@ static int wake_const_ops(struct sem_array *sma, int semnum,
else else
pending_list = &sma->sem_base[semnum].pending_const; pending_list = &sma->sem_base[semnum].pending_const;
walk = pending_list->next; list_for_each_entry_safe(q, tmp, pending_list, list) {
while (walk != pending_list) { int error = perform_atomic_semop(sma, q);
int error;
q = container_of(walk, struct sem_queue, list); if (error > 0)
walk = walk->next; continue;
/* operation completed, remove from queue & wakeup */
unlink_queue(sma, q);
error = perform_atomic_semop(sma, q); wake_up_sem_queue_prepare(q, error, wake_q);
if (error == 0)
if (error <= 0) { semop_completed = 1;
/* operation completed, remove from queue & wakeup */
unlink_queue(sma, q);
wake_up_sem_queue_prepare(q, error, wake_q);
if (error == 0)
semop_completed = 1;
}
} }
return semop_completed; return semop_completed;
} }
@ -914,8 +907,7 @@ static int do_smart_wakeup_zero(struct sem_array *sma, struct sembuf *sops,
*/ */
static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *wake_q) static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *wake_q)
{ {
struct sem_queue *q; struct sem_queue *q, *tmp;
struct list_head *walk;
struct list_head *pending_list; struct list_head *pending_list;
int semop_completed = 0; int semop_completed = 0;
@ -925,13 +917,9 @@ static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *w
pending_list = &sma->sem_base[semnum].pending_alter; pending_list = &sma->sem_base[semnum].pending_alter;
again: again:
walk = pending_list->next; list_for_each_entry_safe(q, tmp, pending_list, list) {
while (walk != pending_list) {
int error, restart; int error, restart;
q = container_of(walk, struct sem_queue, list);
walk = walk->next;
/* If we are scanning the single sop, per-semaphore list of /* If we are scanning the single sop, per-semaphore list of
* one semaphore and that semaphore is 0, then it is not * one semaphore and that semaphore is 0, then it is not
* necessary to scan further: simple increments * necessary to scan further: simple increments