aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-03-26 04:37:17 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:56:55 -0500
commit5f921ae96f1529a55966f25cd5c70fab11d38be7 (patch)
treed8b3fecae1b36a99c0dbf544b30933a727bc7178 /ipc/util.c
parent14cc3e2b633bb64063698980974df4535368e98f (diff)
[PATCH] sem2mutex: ipc, id.sem
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'ipc/util.c')
-rw-r--r--ipc/util.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/ipc/util.c b/ipc/util.c
index 862621980b0..23151ef3259 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -68,7 +68,8 @@ __initcall(ipc_init);
68void __init ipc_init_ids(struct ipc_ids* ids, int size) 68void __init ipc_init_ids(struct ipc_ids* ids, int size)
69{ 69{
70 int i; 70 int i;
71 sema_init(&ids->sem,1); 71
72 mutex_init(&ids->mutex);
72 73
73 if(size > IPCMNI) 74 if(size > IPCMNI)
74 size = IPCMNI; 75 size = IPCMNI;
@@ -138,7 +139,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
138 * @ids: Identifier set 139 * @ids: Identifier set
139 * @key: The key to find 140 * @key: The key to find
140 * 141 *
141 * Requires ipc_ids.sem locked. 142 * Requires ipc_ids.mutex locked.
142 * Returns the identifier if found or -1 if not. 143 * Returns the identifier if found or -1 if not.
143 */ 144 */
144 145
@@ -150,7 +151,7 @@ int ipc_findkey(struct ipc_ids* ids, key_t key)
150 151
151 /* 152 /*
152 * rcu_dereference() is not needed here 153 * rcu_dereference() is not needed here
153 * since ipc_ids.sem is held 154 * since ipc_ids.mutex is held
154 */ 155 */
155 for (id = 0; id <= max_id; id++) { 156 for (id = 0; id <= max_id; id++) {
156 p = ids->entries->p[id]; 157 p = ids->entries->p[id];
@@ -163,7 +164,7 @@ int ipc_findkey(struct ipc_ids* ids, key_t key)
163} 164}
164 165
165/* 166/*
166 * Requires ipc_ids.sem locked 167 * Requires ipc_ids.mutex locked
167 */ 168 */
168static int grow_ary(struct ipc_ids* ids, int newsize) 169static int grow_ary(struct ipc_ids* ids, int newsize)
169{ 170{
@@ -210,7 +211,7 @@ static int grow_ary(struct ipc_ids* ids, int newsize)
210 * is returned. The list is returned in a locked state on success. 211 * is returned. The list is returned in a locked state on success.
211 * On failure the list is not locked and -1 is returned. 212 * On failure the list is not locked and -1 is returned.
212 * 213 *
213 * Called with ipc_ids.sem held. 214 * Called with ipc_ids.mutex held.
214 */ 215 */
215 216
216int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size) 217int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
@@ -221,7 +222,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
221 222
222 /* 223 /*
223 * rcu_dereference()() is not needed here since 224 * rcu_dereference()() is not needed here since
224 * ipc_ids.sem is held 225 * ipc_ids.mutex is held
225 */ 226 */
226 for (id = 0; id < size; id++) { 227 for (id = 0; id < size; id++) {
227 if(ids->entries->p[id] == NULL) 228 if(ids->entries->p[id] == NULL)
@@ -257,7 +258,7 @@ found:
257 * fed an invalid identifier. The entry is removed and internal 258 * fed an invalid identifier. The entry is removed and internal
258 * variables recomputed. The object associated with the identifier 259 * variables recomputed. The object associated with the identifier
259 * is returned. 260 * is returned.
260 * ipc_ids.sem and the spinlock for this ID is hold before this function 261 * ipc_ids.mutex and the spinlock for this ID is hold before this function
261 * is called, and remain locked on the exit. 262 * is called, and remain locked on the exit.
262 */ 263 */
263 264
@@ -270,7 +271,7 @@ struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id)
270 271
271 /* 272 /*
272 * do not need a rcu_dereference()() here to force ordering 273 * do not need a rcu_dereference()() here to force ordering
273 * on Alpha, since the ipc_ids.sem is held. 274 * on Alpha, since the ipc_ids.mutex is held.
274 */ 275 */
275 p = ids->entries->p[lid]; 276 p = ids->entries->p[lid];
276 ids->entries->p[lid] = NULL; 277 ids->entries->p[lid] = NULL;
@@ -530,13 +531,13 @@ void ipc64_perm_to_ipc_perm (struct ipc64_perm *in, struct ipc_perm *out)
530 531
531/* 532/*
532 * So far only shm_get_stat() calls ipc_get() via shm_get(), so ipc_get() 533 * So far only shm_get_stat() calls ipc_get() via shm_get(), so ipc_get()
533 * is called with shm_ids.sem locked. Since grow_ary() is also called with 534 * is called with shm_ids.mutex locked. Since grow_ary() is also called with
534 * shm_ids.sem down(for Shared Memory), there is no need to add read 535 * shm_ids.mutex down(for Shared Memory), there is no need to add read
535 * barriers here to gurantee the writes in grow_ary() are seen in order 536 * barriers here to gurantee the writes in grow_ary() are seen in order
536 * here (for Alpha). 537 * here (for Alpha).
537 * 538 *
538 * However ipc_get() itself does not necessary require ipc_ids.sem down. So 539 * However ipc_get() itself does not necessary require ipc_ids.mutex down. So
539 * if in the future ipc_get() is used by other places without ipc_ids.sem 540 * if in the future ipc_get() is used by other places without ipc_ids.mutex
540 * down, then ipc_get() needs read memery barriers as ipc_lock() does. 541 * down, then ipc_get() needs read memery barriers as ipc_lock() does.
541 */ 542 */
542struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id) 543struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id)
@@ -667,7 +668,7 @@ static void *sysvipc_proc_start(struct seq_file *s, loff_t *pos)
667 * Take the lock - this will be released by the corresponding 668 * Take the lock - this will be released by the corresponding
668 * call to stop(). 669 * call to stop().
669 */ 670 */
670 down(&iface->ids->sem); 671 mutex_lock(&iface->ids->mutex);
671 672
672 /* pos < 0 is invalid */ 673 /* pos < 0 is invalid */
673 if (*pos < 0) 674 if (*pos < 0)
@@ -697,7 +698,7 @@ static void sysvipc_proc_stop(struct seq_file *s, void *it)
697 ipc_unlock(ipc); 698 ipc_unlock(ipc);
698 699
699 /* Release the lock we took in start() */ 700 /* Release the lock we took in start() */
700 up(&iface->ids->sem); 701 mutex_unlock(&iface->ids->mutex);
701} 702}
702 703
703static int sysvipc_proc_show(struct seq_file *s, void *it) 704static int sysvipc_proc_show(struct seq_file *s, void *it)