aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/sem.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <davidlohr.bueso@hp.com>2013-09-11 17:26:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-18 10:45:47 -0400
commit33b74669858f3f1982d83015203264b462d845e7 (patch)
tree518ac3e96b50047e3d14fa13f81c99fe33f02199 /ipc/sem.c
parentbd58e2dc27330012ff1774cd54d41d6e7ffcbc36 (diff)
ipc: rename ids->rw_mutex
commit d9a605e40b1376eb02b067d7690580255a0df68f upstream. Since in some situations the lock can be shared for readers, we shouldn't be calling it a mutex, rename it to rwsem. Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> Cc: Rik van Riel <riel@redhat.com> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'ipc/sem.c')
-rw-r--r--ipc/sem.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index 41088899783d..69b6a21f3844 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -322,7 +322,7 @@ static inline void sem_unlock(struct sem_array *sma, int locknum)
322} 322}
323 323
324/* 324/*
325 * sem_lock_(check_) routines are called in the paths where the rw_mutex 325 * sem_lock_(check_) routines are called in the paths where the rwsem
326 * is not held. 326 * is not held.
327 * 327 *
328 * The caller holds the RCU read lock. 328 * The caller holds the RCU read lock.
@@ -426,7 +426,7 @@ static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s)
426 * @ns: namespace 426 * @ns: namespace
427 * @params: ptr to the structure that contains key, semflg and nsems 427 * @params: ptr to the structure that contains key, semflg and nsems
428 * 428 *
429 * Called with sem_ids.rw_mutex held (as a writer) 429 * Called with sem_ids.rwsem held (as a writer)
430 */ 430 */
431 431
432static int newary(struct ipc_namespace *ns, struct ipc_params *params) 432static int newary(struct ipc_namespace *ns, struct ipc_params *params)
@@ -492,7 +492,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
492 492
493 493
494/* 494/*
495 * Called with sem_ids.rw_mutex and ipcp locked. 495 * Called with sem_ids.rwsem and ipcp locked.
496 */ 496 */
497static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg) 497static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg)
498{ 498{
@@ -503,7 +503,7 @@ static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg)
503} 503}
504 504
505/* 505/*
506 * Called with sem_ids.rw_mutex and ipcp locked. 506 * Called with sem_ids.rwsem and ipcp locked.
507 */ 507 */
508static inline int sem_more_checks(struct kern_ipc_perm *ipcp, 508static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
509 struct ipc_params *params) 509 struct ipc_params *params)
@@ -994,8 +994,8 @@ static int count_semzcnt (struct sem_array * sma, ushort semnum)
994 return semzcnt; 994 return semzcnt;
995} 995}
996 996
997/* Free a semaphore set. freeary() is called with sem_ids.rw_mutex locked 997/* Free a semaphore set. freeary() is called with sem_ids.rwsem locked
998 * as a writer and the spinlock for this semaphore set hold. sem_ids.rw_mutex 998 * as a writer and the spinlock for this semaphore set hold. sem_ids.rwsem
999 * remains locked on exit. 999 * remains locked on exit.
1000 */ 1000 */
1001static void freeary(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) 1001static void freeary(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
@@ -1116,7 +1116,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
1116 seminfo.semmnu = SEMMNU; 1116 seminfo.semmnu = SEMMNU;
1117 seminfo.semmap = SEMMAP; 1117 seminfo.semmap = SEMMAP;
1118 seminfo.semume = SEMUME; 1118 seminfo.semume = SEMUME;
1119 down_read(&sem_ids(ns).rw_mutex); 1119 down_read(&sem_ids(ns).rwsem);
1120 if (cmd == SEM_INFO) { 1120 if (cmd == SEM_INFO) {
1121 seminfo.semusz = sem_ids(ns).in_use; 1121 seminfo.semusz = sem_ids(ns).in_use;
1122 seminfo.semaem = ns->used_sems; 1122 seminfo.semaem = ns->used_sems;
@@ -1125,7 +1125,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
1125 seminfo.semaem = SEMAEM; 1125 seminfo.semaem = SEMAEM;
1126 } 1126 }
1127 max_id = ipc_get_maxid(&sem_ids(ns)); 1127 max_id = ipc_get_maxid(&sem_ids(ns));
1128 up_read(&sem_ids(ns).rw_mutex); 1128 up_read(&sem_ids(ns).rwsem);
1129 if (copy_to_user(p, &seminfo, sizeof(struct seminfo))) 1129 if (copy_to_user(p, &seminfo, sizeof(struct seminfo)))
1130 return -EFAULT; 1130 return -EFAULT;
1131 return (max_id < 0) ? 0: max_id; 1131 return (max_id < 0) ? 0: max_id;
@@ -1431,9 +1431,9 @@ copy_semid_from_user(struct semid64_ds *out, void __user *buf, int version)
1431} 1431}
1432 1432
1433/* 1433/*
1434 * This function handles some semctl commands which require the rw_mutex 1434 * This function handles some semctl commands which require the rwsem
1435 * to be held in write mode. 1435 * to be held in write mode.
1436 * NOTE: no locks must be held, the rw_mutex is taken inside this function. 1436 * NOTE: no locks must be held, the rwsem is taken inside this function.
1437 */ 1437 */
1438static int semctl_down(struct ipc_namespace *ns, int semid, 1438static int semctl_down(struct ipc_namespace *ns, int semid,
1439 int cmd, int version, void __user *p) 1439 int cmd, int version, void __user *p)
@@ -1448,7 +1448,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
1448 return -EFAULT; 1448 return -EFAULT;
1449 } 1449 }
1450 1450
1451 down_write(&sem_ids(ns).rw_mutex); 1451 down_write(&sem_ids(ns).rwsem);
1452 rcu_read_lock(); 1452 rcu_read_lock();
1453 1453
1454 ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd, 1454 ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd,
@@ -1487,7 +1487,7 @@ out_unlock0:
1487out_unlock1: 1487out_unlock1:
1488 rcu_read_unlock(); 1488 rcu_read_unlock();
1489out_up: 1489out_up:
1490 up_write(&sem_ids(ns).rw_mutex); 1490 up_write(&sem_ids(ns).rwsem);
1491 return err; 1491 return err;
1492} 1492}
1493 1493