aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/msg.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <davidlohr.bueso@hp.com>2013-07-08 19:01:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:26 -0400
commitdbfcd91f06f0e2d5564b2fd184e9c2a43675f9ab (patch)
treedff823ad3c61e2b199fb42c71abe81264d60e5dd /ipc/msg.c
parentc103a4dc4a32f53f095b66cd798d648c652f05b4 (diff)
ipc: move rcu lock out of ipc_addid
This patchset continues the work that began in the sysv ipc semaphore scaling series, see https://lkml.org/lkml/2013/3/20/546 Just like semaphores used to be, sysv shared memory and msg queues also abuse the ipc lock, unnecessarily holding it for operations such as permission and security checks. This patchset mostly deals with mqueues, and while shared mem can be done in a very similar way, I want to get these patches out in the open first. It also does some pending cleanups, mostly focused on the two level locking we have in ipc code, taking care of ipc_addid() and ipcctl_pre_down_nolock() - yes there are still functions that need to be updated as well. This patch: Make all callers explicitly take and release the RCU read lock. This addresses the two level locking seen in newary(), newseg() and newqueue(). For the last two, explicitly unlock the ipc object and the rcu lock, instead of calling the custom shm_unlock and msg_unlock functions. The next patch will deal with the open coded locking for ->perm.lock Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/msg.c')
-rw-r--r--ipc/msg.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index d0c6d967b390..996feb819248 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -199,9 +199,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
199 return retval; 199 return retval;
200 } 200 }
201 201
202 /* 202 /* ipc_addid() locks msq upon success. */
203 * ipc_addid() locks msq
204 */
205 id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); 203 id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);
206 if (id < 0) { 204 if (id < 0) {
207 security_msg_queue_free(msq); 205 security_msg_queue_free(msq);
@@ -218,7 +216,8 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
218 INIT_LIST_HEAD(&msq->q_receivers); 216 INIT_LIST_HEAD(&msq->q_receivers);
219 INIT_LIST_HEAD(&msq->q_senders); 217 INIT_LIST_HEAD(&msq->q_senders);
220 218
221 msg_unlock(msq); 219 spin_unlock(&msq->q_perm.lock);
220 rcu_read_unlock();
222 221
223 return msq->q_perm.id; 222 return msq->q_perm.id;
224} 223}