summaryrefslogtreecommitdiffstats
path: root/ipc/sem.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2016-12-14 18:06:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-14 19:04:08 -0500
commitf150f02cfbc7b6b980e260856555abd73235a6b0 (patch)
treed7872d6961c6c9f72598089c716aab16404085d0 /ipc/sem.c
parent4663d3e8f21652f33c698fcc2bf20f61499d9c3e (diff)
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>
Diffstat (limited to 'ipc/sem.c')
-rw-r--r--ipc/sem.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index 084e1f55ca72..4f5af6e7d630 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -813,8 +813,7 @@ static inline int check_restart(struct sem_array *sma, struct sem_queue *q)
813static int wake_const_ops(struct sem_array *sma, int semnum, 813static int wake_const_ops(struct sem_array *sma, int semnum,
814 struct wake_q_head *wake_q) 814 struct wake_q_head *wake_q)
815{ 815{
816 struct sem_queue *q; 816 struct sem_queue *q, *tmp;
817 struct list_head *walk;
818 struct list_head *pending_list; 817 struct list_head *pending_list;
819 int semop_completed = 0; 818 int semop_completed = 0;
820 819
@@ -823,25 +822,19 @@ static int wake_const_ops(struct sem_array *sma, int semnum,
823 else 822 else
824 pending_list = &sma->sem_base[semnum].pending_const; 823 pending_list = &sma->sem_base[semnum].pending_const;
825 824
826 walk = pending_list->next; 825 list_for_each_entry_safe(q, tmp, pending_list, list) {
827 while (walk != pending_list) { 826 int error = perform_atomic_semop(sma, q);
828 int error;
829
830 q = container_of(walk, struct sem_queue, list);
831 walk = walk->next;
832
833 error = perform_atomic_semop(sma, q);
834
835 if (error <= 0) {
836 /* operation completed, remove from queue & wakeup */
837 827
838 unlink_queue(sma, q); 828 if (error > 0)
829 continue;
830 /* operation completed, remove from queue & wakeup */
831 unlink_queue(sma, q);
839 832
840 wake_up_sem_queue_prepare(q, error, wake_q); 833 wake_up_sem_queue_prepare(q, error, wake_q);
841 if (error == 0) 834 if (error == 0)
842 semop_completed = 1; 835 semop_completed = 1;
843 }
844 } 836 }
837
845 return semop_completed; 838 return semop_completed;
846} 839}
847 840
@@ -914,8 +907,7 @@ static int do_smart_wakeup_zero(struct sem_array *sma, struct sembuf *sops,
914 */ 907 */
915static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *wake_q) 908static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *wake_q)
916{ 909{
917 struct sem_queue *q; 910 struct sem_queue *q, *tmp;
918 struct list_head *walk;
919 struct list_head *pending_list; 911 struct list_head *pending_list;
920 int semop_completed = 0; 912 int semop_completed = 0;
921 913
@@ -925,13 +917,9 @@ static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *w
925 pending_list = &sma->sem_base[semnum].pending_alter; 917 pending_list = &sma->sem_base[semnum].pending_alter;
926 918
927again: 919again:
928 walk = pending_list->next; 920 list_for_each_entry_safe(q, tmp, pending_list, list) {
929 while (walk != pending_list) {
930 int error, restart; 921 int error, restart;
931 922
932 q = container_of(walk, struct sem_queue, list);
933 walk = walk->next;
934
935 /* If we are scanning the single sop, per-semaphore list of 923 /* If we are scanning the single sop, per-semaphore list of
936 * one semaphore and that semaphore is 0, then it is not 924 * one semaphore and that semaphore is 0, then it is not
937 * necessary to scan further: simple increments 925 * necessary to scan further: simple increments