aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2014-02-03 22:13:49 -0500
committerEric W. Biederman <ebiederm@xmission.com>2014-07-29 21:08:50 -0400
commit728dba3a39c66b3d8ac889ddbe38b5b1c264aec3 (patch)
tree26f69d0fe363f00b628d698b9df2634a33e42482 /ipc
parent9a3c4145af32125c5ee39c0272662b47307a8323 (diff)
namespaces: Use task_lock and not rcu to protect nsproxy
The synchronous syncrhonize_rcu in switch_task_namespaces makes setns a sufficiently expensive system call that people have complained. Upon inspect nsproxy no longer needs rcu protection for remote reads. remote reads are rare. So optimize for same process reads and write by switching using rask_lock instead. This yields a simpler to understand lock, and a faster setns system call. In particular this fixes a performance regression observed by Rafael David Tinoco <rafael.tinoco@canonical.com>. This is effectively a revert of Pavel Emelyanov's commit cf7b708c8d1d7a27736771bcf4c457b332b0f818 Make access to task's nsproxy lighter from 2007. The race this originialy fixed no longer exists as do_notify_parent uses task_active_pid_ns(parent) instead of parent->nsproxy. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/namespace.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ipc/namespace.c b/ipc/namespace.c
index 59451c1e214d..b54468e48e32 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -154,11 +154,11 @@ static void *ipcns_get(struct task_struct *task)
154 struct ipc_namespace *ns = NULL; 154 struct ipc_namespace *ns = NULL;
155 struct nsproxy *nsproxy; 155 struct nsproxy *nsproxy;
156 156
157 rcu_read_lock(); 157 task_lock(task);
158 nsproxy = task_nsproxy(task); 158 nsproxy = task->nsproxy;
159 if (nsproxy) 159 if (nsproxy)
160 ns = get_ipc_ns(nsproxy->ipc_ns); 160 ns = get_ipc_ns(nsproxy->ipc_ns);
161 rcu_read_unlock(); 161 task_unlock(task);
162 162
163 return ns; 163 return ns;
164} 164}