diff options
| author | Manfred Spraul <manfred@colorfullife.com> | 2013-07-08 19:01:26 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-09 13:33:28 -0400 |
| commit | 758a6ba39ef6df4cdc615e5edd7bd86eab81a5f7 (patch) | |
| tree | 519c1f2e672e888c04b5447a85ad78aa08c1c693 /ipc | |
| parent | d12e1e50e47e0900dbbf52237b7e171f4f15ea1e (diff) | |
ipc/sem.c: rename try_atomic_semop() to perform_atomic_semop(), docu update
Cleanup: Some minor points that I noticed while writing the previous
patches
1) The name try_atomic_semop() is misleading: The function performs the
operation (if it is possible).
2) Some documentation updates.
No real code change, a rename and documentation changes.
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Davidlohr Bueso <davidlohr.bueso@hp.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 | 32 |
1 files changed, 21 insertions, 11 deletions
| @@ -154,12 +154,15 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it); | |||
| 154 | #define SEMOPM_FAST 64 /* ~ 372 bytes on stack */ | 154 | #define SEMOPM_FAST 64 /* ~ 372 bytes on stack */ |
| 155 | 155 | ||
| 156 | /* | 156 | /* |
| 157 | * linked list protection: | 157 | * Locking: |
| 158 | * sem_undo.id_next, | 158 | * sem_undo.id_next, |
| 159 | * sem_array.complex_count, | ||
| 159 | * sem_array.pending{_alter,_cont}, | 160 | * sem_array.pending{_alter,_cont}, |
| 160 | * sem_array.sem_undo: sem_lock() for read/write | 161 | * sem_array.sem_undo: global sem_lock() for read/write |
| 161 | * sem_undo.proc_next: only "current" is allowed to read/write that field. | 162 | * sem_undo.proc_next: only "current" is allowed to read/write that field. |
| 162 | * | 163 | * |
| 164 | * sem_array.sem_base[i].pending_{const,alter}: | ||
| 165 | * global or semaphore sem_lock() for read/write | ||
| 163 | */ | 166 | */ |
| 164 | 167 | ||
| 165 | #define sc_semmsl sem_ctls[0] | 168 | #define sc_semmsl sem_ctls[0] |
| @@ -536,12 +539,19 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) | |||
| 536 | return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params); | 539 | return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params); |
| 537 | } | 540 | } |
| 538 | 541 | ||
| 539 | /* | 542 | /** perform_atomic_semop - Perform (if possible) a semaphore operation |
| 540 | * Determine whether a sequence of semaphore operations would succeed | 543 | * @sma: semaphore array |
| 541 | * all at once. Return 0 if yes, 1 if need to sleep, else return error code. | 544 | * @sops: array with operations that should be checked |
| 545 | * @nsems: number of sops | ||
| 546 | * @un: undo array | ||
| 547 | * @pid: pid that did the change | ||
| 548 | * | ||
| 549 | * Returns 0 if the operation was possible. | ||
| 550 | * Returns 1 if the operation is impossible, the caller must sleep. | ||
| 551 | * Negative values are error codes. | ||
| 542 | */ | 552 | */ |
| 543 | 553 | ||
| 544 | static int try_atomic_semop (struct sem_array * sma, struct sembuf * sops, | 554 | static int perform_atomic_semop(struct sem_array *sma, struct sembuf *sops, |
| 545 | int nsops, struct sem_undo *un, int pid) | 555 | int nsops, struct sem_undo *un, int pid) |
| 546 | { | 556 | { |
| 547 | int result, sem_op; | 557 | int result, sem_op; |
| @@ -724,8 +734,8 @@ static int wake_const_ops(struct sem_array *sma, int semnum, | |||
| 724 | q = container_of(walk, struct sem_queue, list); | 734 | q = container_of(walk, struct sem_queue, list); |
| 725 | walk = walk->next; | 735 | walk = walk->next; |
| 726 | 736 | ||
| 727 | error = try_atomic_semop(sma, q->sops, q->nsops, | 737 | error = perform_atomic_semop(sma, q->sops, q->nsops, |
| 728 | q->undo, q->pid); | 738 | q->undo, q->pid); |
| 729 | 739 | ||
| 730 | if (error <= 0) { | 740 | if (error <= 0) { |
| 731 | /* operation completed, remove from queue & wakeup */ | 741 | /* operation completed, remove from queue & wakeup */ |
| @@ -838,7 +848,7 @@ again: | |||
| 838 | if (semnum != -1 && sma->sem_base[semnum].semval == 0) | 848 | if (semnum != -1 && sma->sem_base[semnum].semval == 0) |
| 839 | break; | 849 | break; |
| 840 | 850 | ||
| 841 | error = try_atomic_semop(sma, q->sops, q->nsops, | 851 | error = perform_atomic_semop(sma, q->sops, q->nsops, |
| 842 | q->undo, q->pid); | 852 | q->undo, q->pid); |
| 843 | 853 | ||
| 844 | /* Does q->sleeper still need to sleep? */ | 854 | /* Does q->sleeper still need to sleep? */ |
| @@ -1686,7 +1696,6 @@ static int get_queue_result(struct sem_queue *q) | |||
| 1686 | return error; | 1696 | return error; |
| 1687 | } | 1697 | } |
| 1688 | 1698 | ||
| 1689 | |||
| 1690 | SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | 1699 | SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, |
| 1691 | unsigned, nsops, const struct timespec __user *, timeout) | 1700 | unsigned, nsops, const struct timespec __user *, timeout) |
| 1692 | { | 1701 | { |
| @@ -1784,7 +1793,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
| 1784 | if (un && un->semid == -1) | 1793 | if (un && un->semid == -1) |
| 1785 | goto out_unlock_free; | 1794 | goto out_unlock_free; |
| 1786 | 1795 | ||
| 1787 | error = try_atomic_semop (sma, sops, nsops, un, task_tgid_vnr(current)); | 1796 | error = perform_atomic_semop(sma, sops, nsops, un, |
| 1797 | task_tgid_vnr(current)); | ||
| 1788 | if (error <= 0) { | 1798 | if (error <= 0) { |
| 1789 | if (alter && error == 0) | 1799 | if (alter && error == 0) |
| 1790 | do_smart_update(sma, sops, nsops, 1, &tasks); | 1800 | do_smart_update(sma, sops, nsops, 1, &tasks); |
