diff options
author | Manfred Spraul <manfred@colorfullife.com> | 2014-06-06 17:37:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-06 19:08:15 -0400 |
commit | d198cd6d6d02d0a335af2deacb60816ebb4719d1 (patch) | |
tree | daeed09468d467dbddb1be28281f0f7abd6d8160 /ipc | |
parent | 2f2ed41dcaec34f2d6f224aa84efcc5a9dd8d5c3 (diff) |
ipc/sem.c: change perform_atomic_semop parameters
Right now, perform_atomic_semop gets the content of sem_queue as
individual fields. Changes that, instead pass a pointer to sem_queue.
This is a preparation for the next patch: it uses sem_queue to store the
reason why a task must sleep.
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Davidlohr Bueso <davidlohr.bueso@hp.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/sem.c | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -585,21 +585,23 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) | |||
585 | /** | 585 | /** |
586 | * perform_atomic_semop - Perform (if possible) a semaphore operation | 586 | * perform_atomic_semop - Perform (if possible) a semaphore operation |
587 | * @sma: semaphore array | 587 | * @sma: semaphore array |
588 | * @sops: array with operations that should be checked | 588 | * @q: struct sem_queue that describes the operation |
589 | * @nsops: number of operations | ||
590 | * @un: undo array | ||
591 | * @pid: pid that did the change | ||
592 | * | 589 | * |
593 | * Returns 0 if the operation was possible. | 590 | * Returns 0 if the operation was possible. |
594 | * Returns 1 if the operation is impossible, the caller must sleep. | 591 | * Returns 1 if the operation is impossible, the caller must sleep. |
595 | * Negative values are error codes. | 592 | * Negative values are error codes. |
596 | */ | 593 | */ |
597 | static int perform_atomic_semop(struct sem_array *sma, struct sembuf *sops, | 594 | static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q) |
598 | int nsops, struct sem_undo *un, int pid) | ||
599 | { | 595 | { |
600 | int result, sem_op; | 596 | int result, sem_op, nsops, pid; |
601 | struct sembuf *sop; | 597 | struct sembuf *sop; |
602 | struct sem *curr; | 598 | struct sem *curr; |
599 | struct sembuf *sops; | ||
600 | struct sem_undo *un; | ||
601 | |||
602 | sops = q->sops; | ||
603 | nsops = q->nsops; | ||
604 | un = q->undo; | ||
603 | 605 | ||
604 | for (sop = sops; sop < sops + nsops; sop++) { | 606 | for (sop = sops; sop < sops + nsops; sop++) { |
605 | curr = sma->sem_base + sop->sem_num; | 607 | curr = sma->sem_base + sop->sem_num; |
@@ -627,6 +629,7 @@ static int perform_atomic_semop(struct sem_array *sma, struct sembuf *sops, | |||
627 | } | 629 | } |
628 | 630 | ||
629 | sop--; | 631 | sop--; |
632 | pid = q->pid; | ||
630 | while (sop >= sops) { | 633 | while (sop >= sops) { |
631 | sma->sem_base[sop->sem_num].sempid = pid; | 634 | sma->sem_base[sop->sem_num].sempid = pid; |
632 | sop--; | 635 | sop--; |
@@ -779,8 +782,7 @@ static int wake_const_ops(struct sem_array *sma, int semnum, | |||
779 | q = container_of(walk, struct sem_queue, list); | 782 | q = container_of(walk, struct sem_queue, list); |
780 | walk = walk->next; | 783 | walk = walk->next; |
781 | 784 | ||
782 | error = perform_atomic_semop(sma, q->sops, q->nsops, | 785 | error = perform_atomic_semop(sma, q); |
783 | q->undo, q->pid); | ||
784 | 786 | ||
785 | if (error <= 0) { | 787 | if (error <= 0) { |
786 | /* operation completed, remove from queue & wakeup */ | 788 | /* operation completed, remove from queue & wakeup */ |
@@ -892,8 +894,7 @@ again: | |||
892 | if (semnum != -1 && sma->sem_base[semnum].semval == 0) | 894 | if (semnum != -1 && sma->sem_base[semnum].semval == 0) |
893 | break; | 895 | break; |
894 | 896 | ||
895 | error = perform_atomic_semop(sma, q->sops, q->nsops, | 897 | error = perform_atomic_semop(sma, q); |
896 | q->undo, q->pid); | ||
897 | 898 | ||
898 | /* Does q->sleeper still need to sleep? */ | 899 | /* Does q->sleeper still need to sleep? */ |
899 | if (error > 0) | 900 | if (error > 0) |
@@ -1871,8 +1872,13 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
1871 | if (un && un->semid == -1) | 1872 | if (un && un->semid == -1) |
1872 | goto out_unlock_free; | 1873 | goto out_unlock_free; |
1873 | 1874 | ||
1874 | error = perform_atomic_semop(sma, sops, nsops, un, | 1875 | queue.sops = sops; |
1875 | task_tgid_vnr(current)); | 1876 | queue.nsops = nsops; |
1877 | queue.undo = un; | ||
1878 | queue.pid = task_tgid_vnr(current); | ||
1879 | queue.alter = alter; | ||
1880 | |||
1881 | error = perform_atomic_semop(sma, &queue); | ||
1876 | if (error == 0) { | 1882 | if (error == 0) { |
1877 | /* If the operation was successful, then do | 1883 | /* If the operation was successful, then do |
1878 | * the required updates. | 1884 | * the required updates. |
@@ -1889,12 +1895,6 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
1889 | * task into the pending queue and go to sleep. | 1895 | * task into the pending queue and go to sleep. |
1890 | */ | 1896 | */ |
1891 | 1897 | ||
1892 | queue.sops = sops; | ||
1893 | queue.nsops = nsops; | ||
1894 | queue.undo = un; | ||
1895 | queue.pid = task_tgid_vnr(current); | ||
1896 | queue.alter = alter; | ||
1897 | |||
1898 | if (nsops == 1) { | 1898 | if (nsops == 1) { |
1899 | struct sem *curr; | 1899 | struct sem *curr; |
1900 | curr = &sma->sem_base[sops->sem_num]; | 1900 | curr = &sma->sem_base[sops->sem_num]; |