Skip to content

Commit b607656

Browse files
Davidlohr Buesogregkh
authored andcommitted
ipc: rename ids->rw_mutex
commit d9a605e 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>
1 parent 19dfd03 commit b607656

7 files changed

Lines changed: 69 additions & 69 deletions

File tree

‎include/linux/ipc_namespace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct ipc_ids {
2222
int in_use;
2323
unsigned short seq;
2424
unsigned short seq_max;
25-
struct rw_semaphore rw_mutex;
25+
struct rw_semaphore rwsem;
2626
struct idr ipcs_idr;
2727
int next_id;
2828
};

‎ipc/msg.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void msg_rcu_free(struct rcu_head *head)
181181
* @ns: namespace
182182
* @params: ptr to the structure that contains the key and msgflg
183183
*
184-
* Called with msg_ids.rw_mutex held (writer)
184+
* Called with msg_ids.rwsem held (writer)
185185
*/
186186
static int newque(struct ipc_namespace *ns, struct ipc_params *params)
187187
{
@@ -267,8 +267,8 @@ static void expunge_all(struct msg_queue *msq, int res)
267267
* removes the message queue from message queue ID IDR, and cleans up all the
268268
* messages associated with this queue.
269269
*
270-
* msg_ids.rw_mutex (writer) and the spinlock for this message queue are held
271-
* before freeque() is called. msg_ids.rw_mutex remains locked on exit.
270+
* msg_ids.rwsem (writer) and the spinlock for this message queue are held
271+
* before freeque() is called. msg_ids.rwsem remains locked on exit.
272272
*/
273273
static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
274274
{
@@ -289,7 +289,7 @@ static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
289289
}
290290

291291
/*
292-
* Called with msg_ids.rw_mutex and ipcp locked.
292+
* Called with msg_ids.rwsem and ipcp locked.
293293
*/
294294
static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
295295
{
@@ -393,9 +393,9 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version)
393393
}
394394

395395
/*
396-
* This function handles some msgctl commands which require the rw_mutex
396+
* This function handles some msgctl commands which require the rwsem
397397
* to be held in write mode.
398-
* NOTE: no locks must be held, the rw_mutex is taken inside this function.
398+
* NOTE: no locks must be held, the rwsem is taken inside this function.
399399
*/
400400
static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
401401
struct msqid_ds __user *buf, int version)
@@ -410,7 +410,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
410410
return -EFAULT;
411411
}
412412

413-
down_write(&msg_ids(ns).rw_mutex);
413+
down_write(&msg_ids(ns).rwsem);
414414
rcu_read_lock();
415415

416416
ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd,
@@ -466,7 +466,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
466466
out_unlock1:
467467
rcu_read_unlock();
468468
out_up:
469-
up_write(&msg_ids(ns).rw_mutex);
469+
up_write(&msg_ids(ns).rwsem);
470470
return err;
471471
}
472472

@@ -501,7 +501,7 @@ static int msgctl_nolock(struct ipc_namespace *ns, int msqid,
501501
msginfo.msgmnb = ns->msg_ctlmnb;
502502
msginfo.msgssz = MSGSSZ;
503503
msginfo.msgseg = MSGSEG;
504-
down_read(&msg_ids(ns).rw_mutex);
504+
down_read(&msg_ids(ns).rwsem);
505505
if (cmd == MSG_INFO) {
506506
msginfo.msgpool = msg_ids(ns).in_use;
507507
msginfo.msgmap = atomic_read(&ns->msg_hdrs);
@@ -512,7 +512,7 @@ static int msgctl_nolock(struct ipc_namespace *ns, int msqid,
512512
msginfo.msgtql = MSGTQL;
513513
}
514514
max_id = ipc_get_maxid(&msg_ids(ns));
515-
up_read(&msg_ids(ns).rw_mutex);
515+
up_read(&msg_ids(ns).rwsem);
516516
if (copy_to_user(buf, &msginfo, sizeof(struct msginfo)))
517517
return -EFAULT;
518518
return (max_id < 0) ? 0 : max_id;

‎ipc/namespace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
8181
int next_id;
8282
int total, in_use;
8383

84-
down_write(&ids->rw_mutex);
84+
down_write(&ids->rwsem);
8585

8686
in_use = ids->in_use;
8787

@@ -93,7 +93,7 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
9393
free(ns, perm);
9494
total++;
9595
}
96-
up_write(&ids->rw_mutex);
96+
up_write(&ids->rwsem);
9797
}
9898

9999
static void free_ipc_ns(struct ipc_namespace *ns)

‎ipc/sem.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static inline void sem_unlock(struct sem_array *sma, int locknum)
365365
}
366366

367367
/*
368-
* sem_lock_(check_) routines are called in the paths where the rw_mutex
368+
* sem_lock_(check_) routines are called in the paths where the rwsem
369369
* is not held.
370370
*
371371
* The caller holds the RCU read lock.
@@ -464,7 +464,7 @@ static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s)
464464
* @ns: namespace
465465
* @params: ptr to the structure that contains key, semflg and nsems
466466
*
467-
* Called with sem_ids.rw_mutex held (as a writer)
467+
* Called with sem_ids.rwsem held (as a writer)
468468
*/
469469

470470
static int newary(struct ipc_namespace *ns, struct ipc_params *params)
@@ -529,7 +529,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
529529

530530

531531
/*
532-
* Called with sem_ids.rw_mutex and ipcp locked.
532+
* Called with sem_ids.rwsem and ipcp locked.
533533
*/
534534
static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg)
535535
{
@@ -540,7 +540,7 @@ static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg)
540540
}
541541

542542
/*
543-
* Called with sem_ids.rw_mutex and ipcp locked.
543+
* Called with sem_ids.rwsem and ipcp locked.
544544
*/
545545
static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
546546
struct ipc_params *params)
@@ -1031,8 +1031,8 @@ static int count_semzcnt (struct sem_array * sma, ushort semnum)
10311031
return semzcnt;
10321032
}
10331033

1034-
/* Free a semaphore set. freeary() is called with sem_ids.rw_mutex locked
1035-
* as a writer and the spinlock for this semaphore set hold. sem_ids.rw_mutex
1034+
/* Free a semaphore set. freeary() is called with sem_ids.rwsem locked
1035+
* as a writer and the spinlock for this semaphore set hold. sem_ids.rwsem
10361036
* remains locked on exit.
10371037
*/
10381038
static void freeary(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
@@ -1152,7 +1152,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
11521152
seminfo.semmnu = SEMMNU;
11531153
seminfo.semmap = SEMMAP;
11541154
seminfo.semume = SEMUME;
1155-
down_read(&sem_ids(ns).rw_mutex);
1155+
down_read(&sem_ids(ns).rwsem);
11561156
if (cmd == SEM_INFO) {
11571157
seminfo.semusz = sem_ids(ns).in_use;
11581158
seminfo.semaem = ns->used_sems;
@@ -1161,7 +1161,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
11611161
seminfo.semaem = SEMAEM;
11621162
}
11631163
max_id = ipc_get_maxid(&sem_ids(ns));
1164-
up_read(&sem_ids(ns).rw_mutex);
1164+
up_read(&sem_ids(ns).rwsem);
11651165
if (copy_to_user(p, &seminfo, sizeof(struct seminfo)))
11661166
return -EFAULT;
11671167
return (max_id < 0) ? 0: max_id;
@@ -1467,9 +1467,9 @@ copy_semid_from_user(struct semid64_ds *out, void __user *buf, int version)
14671467
}
14681468

14691469
/*
1470-
* This function handles some semctl commands which require the rw_mutex
1470+
* This function handles some semctl commands which require the rwsem
14711471
* to be held in write mode.
1472-
* NOTE: no locks must be held, the rw_mutex is taken inside this function.
1472+
* NOTE: no locks must be held, the rwsem is taken inside this function.
14731473
*/
14741474
static int semctl_down(struct ipc_namespace *ns, int semid,
14751475
int cmd, int version, void __user *p)
@@ -1484,7 +1484,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
14841484
return -EFAULT;
14851485
}
14861486

1487-
down_write(&sem_ids(ns).rw_mutex);
1487+
down_write(&sem_ids(ns).rwsem);
14881488
rcu_read_lock();
14891489

14901490
ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd,
@@ -1523,7 +1523,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid,
15231523
out_unlock1:
15241524
rcu_read_unlock();
15251525
out_up:
1526-
up_write(&sem_ids(ns).rw_mutex);
1526+
up_write(&sem_ids(ns).rwsem);
15271527
return err;
15281528
}
15291529

0 commit comments

Comments
 (0)