Skip to content

Commit 758a6ba

Browse files
manfred-colorfutorvalds
authored andcommitted
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>
1 parent d12e1e5 commit 758a6ba

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

‎ipc/sem.c‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,15 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it);
154154
#define SEMOPM_FAST 64 /* ~ 372 bytes on stack */
155155

156156
/*
157-
* linked list protection:
157+
* Locking:
158158
* sem_undo.id_next,
159+
* sem_array.complex_count,
159160
* 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
161162
* sem_undo.proc_next: only "current" is allowed to read/write that field.
162163
*
164+
* sem_array.sem_base[i].pending_{const,alter}:
165+
* global or semaphore sem_lock() for read/write
163166
*/
164167

165168
#define sc_semmsl sem_ctls[0]
@@ -536,12 +539,19 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
536539
return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params);
537540
}
538541

539-
/*
540-
* Determine whether a sequence of semaphore operations would succeed
541-
* all at once. Return 0 if yes, 1 if need to sleep, else return error code.
542+
/** perform_atomic_semop - Perform (if possible) a semaphore operation
543+
* @sma: semaphore array
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.
542552
*/
543553

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,
545555
int nsops, struct sem_undo *un, int pid)
546556
{
547557
int result, sem_op;
@@ -724,8 +734,8 @@ static int wake_const_ops(struct sem_array *sma, int semnum,
724734
q = container_of(walk, struct sem_queue, list);
725735
walk = walk->next;
726736

727-
error = try_atomic_semop(sma, q->sops, q->nsops,
728-
q->undo, q->pid);
737+
error = perform_atomic_semop(sma, q->sops, q->nsops,
738+
q->undo, q->pid);
729739

730740
if (error <= 0) {
731741
/* operation completed, remove from queue & wakeup */
@@ -838,7 +848,7 @@ static int update_queue(struct sem_array *sma, int semnum, struct list_head *pt)
838848
if (semnum != -1 && sma->sem_base[semnum].semval == 0)
839849
break;
840850

841-
error = try_atomic_semop(sma, q->sops, q->nsops,
851+
error = perform_atomic_semop(sma, q->sops, q->nsops,
842852
q->undo, q->pid);
843853

844854
/* Does q->sleeper still need to sleep? */
@@ -1686,7 +1696,6 @@ static int get_queue_result(struct sem_queue *q)
16861696
return error;
16871697
}
16881698

1689-
16901699
SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
16911700
unsigned, nsops, const struct timespec __user *, timeout)
16921701
{
@@ -1784,7 +1793,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
17841793
if (un && un->semid == -1)
17851794
goto out_unlock_free;
17861795

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));
17881798
if (error <= 0) {
17891799
if (alter && error == 0)
17901800
do_smart_update(sma, sops, nsops, 1, &tasks);

0 commit comments

Comments
 (0)