aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2010-03-02 17:51:53 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-11-19 08:59:09 -0500
commit17cf22c33e1f1b5e435469c84e43872579497653 (patch)
treec5cec307c06f7e4ddc26e04e73c8833897b67113
parent49f4d8b93ccf9454284b6f524b96c66d8d7fbccc (diff)
pidns: Use task_active_pid_ns where appropriate
The expressions tsk->nsproxy->pid_ns and task_active_pid_ns aka ns_of_pid(task_pid(tsk)) should have the same number of cache line misses with the practical difference that ns_of_pid(task_pid(tsk)) is released later in a processes life. Furthermore by using task_active_pid_ns it becomes trivial to write an unshare implementation for the the pid namespace. So I have used task_active_pid_ns everywhere I can. In fork since the pid has not yet been attached to the process I use ns_of_pid, to achieve the same effect. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c2
-rw-r--r--arch/um/drivers/mconsole_kern.c2
-rw-r--r--drivers/staging/android/binder.c3
-rw-r--r--fs/hppfs/hppfs.c2
-rw-r--r--fs/proc/root.c2
-rw-r--r--kernel/cgroup.c2
-rw-r--r--kernel/events/core.c2
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/nsproxy.c2
-rw-r--r--kernel/pid.c8
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sysctl_binary.c2
12 files changed, 16 insertions, 15 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 965d381abd7..25db92a8e1c 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -1094,7 +1094,7 @@ static int show_spu_loadavg(struct seq_file *s, void *private)
1094 LOAD_INT(c), LOAD_FRAC(c), 1094 LOAD_INT(c), LOAD_FRAC(c),
1095 count_active_contexts(), 1095 count_active_contexts(),
1096 atomic_read(&nr_spu_contexts), 1096 atomic_read(&nr_spu_contexts),
1097 current->nsproxy->pid_ns->last_pid); 1097 task_active_pid_ns(current)->last_pid);
1098 return 0; 1098 return 0;
1099} 1099}
1100 1100
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 79ccfe6c707..7fc71c62826 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -123,7 +123,7 @@ void mconsole_log(struct mc_request *req)
123 123
124void mconsole_proc(struct mc_request *req) 124void mconsole_proc(struct mc_request *req)
125{ 125{
126 struct vfsmount *mnt = current->nsproxy->pid_ns->proc_mnt; 126 struct vfsmount *mnt = task_active_pid_ns(current)->proc_mnt;
127 char *buf; 127 char *buf;
128 int len; 128 int len;
129 struct file *file; 129 struct file *file;
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 5d4610babd8..a97bbcd1c9e 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -33,6 +33,7 @@
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/pid_namespace.h>
36 37
37#include "binder.h" 38#include "binder.h"
38 39
@@ -2344,7 +2345,7 @@ retry:
2344 if (t->from) { 2345 if (t->from) {
2345 struct task_struct *sender = t->from->proc->tsk; 2346 struct task_struct *sender = t->from->proc->tsk;
2346 tr.sender_pid = task_tgid_nr_ns(sender, 2347 tr.sender_pid = task_tgid_nr_ns(sender,
2347 current->nsproxy->pid_ns); 2348 task_active_pid_ns(current));
2348 } else { 2349 } else {
2349 tr.sender_pid = 0; 2350 tr.sender_pid = 0;
2350 } 2351 }
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 78f21f8dc2e..43b315f2002 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -710,7 +710,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
710 struct vfsmount *proc_mnt; 710 struct vfsmount *proc_mnt;
711 int err = -ENOENT; 711 int err = -ENOENT;
712 712
713 proc_mnt = mntget(current->nsproxy->pid_ns->proc_mnt); 713 proc_mnt = mntget(task_active_pid_ns(current)->proc_mnt);
714 if (IS_ERR(proc_mnt)) 714 if (IS_ERR(proc_mnt))
715 goto out; 715 goto out;
716 716
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 13ef6247e7a..fc1609321a7 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -106,7 +106,7 @@ static struct dentry *proc_mount(struct file_system_type *fs_type,
106 ns = (struct pid_namespace *)data; 106 ns = (struct pid_namespace *)data;
107 options = NULL; 107 options = NULL;
108 } else { 108 } else {
109 ns = current->nsproxy->pid_ns; 109 ns = task_active_pid_ns(current);
110 options = data; 110 options = data;
111 } 111 }
112 112
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index f24f724620d..0dbfba2efa7 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3390,7 +3390,7 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
3390{ 3390{
3391 struct cgroup_pidlist *l; 3391 struct cgroup_pidlist *l;
3392 /* don't need task_nsproxy() if we're looking at ourself */ 3392 /* don't need task_nsproxy() if we're looking at ourself */
3393 struct pid_namespace *ns = current->nsproxy->pid_ns; 3393 struct pid_namespace *ns = task_active_pid_ns(current);
3394 3394
3395 /* 3395 /*
3396 * We can't drop the pidlist_mutex before taking the l->mutex in case 3396 * We can't drop the pidlist_mutex before taking the l->mutex in case
diff --git a/kernel/events/core.c b/kernel/events/core.c
index dbccf83c134..738f3564e83 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6155,7 +6155,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
6155 6155
6156 event->parent = parent_event; 6156 event->parent = parent_event;
6157 6157
6158 event->ns = get_pid_ns(current->nsproxy->pid_ns); 6158 event->ns = get_pid_ns(task_active_pid_ns(current));
6159 event->id = atomic64_inc_return(&perf_event_id); 6159 event->id = atomic64_inc_return(&perf_event_id);
6160 6160
6161 event->state = PERF_EVENT_STATE_INACTIVE; 6161 event->state = PERF_EVENT_STATE_INACTIVE;
diff --git a/kernel/fork.c b/kernel/fork.c
index 8b20ab7d3aa..7798c247f4b 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1442,7 +1442,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1442 1442
1443 if (thread_group_leader(p)) { 1443 if (thread_group_leader(p)) {
1444 if (is_child_reaper(pid)) 1444 if (is_child_reaper(pid))
1445 p->nsproxy->pid_ns->child_reaper = p; 1445 ns_of_pid(pid)->child_reaper = p;
1446 1446
1447 p->signal->leader_pid = pid; 1447 p->signal->leader_pid = pid;
1448 p->signal->tty = tty_kref_get(current->signal->tty); 1448 p->signal->tty = tty_kref_get(current->signal->tty);
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index ca27d2c5264..acc92680381 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -84,7 +84,7 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
84 goto out_ipc; 84 goto out_ipc;
85 } 85 }
86 86
87 new_nsp->pid_ns = copy_pid_ns(flags, task_cred_xxx(tsk, user_ns), task_active_pid_ns(tsk)); 87 new_nsp->pid_ns = copy_pid_ns(flags, task_cred_xxx(tsk, user_ns), tsk->nsproxy->pid_ns);
88 if (IS_ERR(new_nsp->pid_ns)) { 88 if (IS_ERR(new_nsp->pid_ns)) {
89 err = PTR_ERR(new_nsp->pid_ns); 89 err = PTR_ERR(new_nsp->pid_ns);
90 goto out_pid; 90 goto out_pid;
diff --git a/kernel/pid.c b/kernel/pid.c
index 2a624f1486e..3a5f238c1ca 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
345 345
346struct pid *find_vpid(int nr) 346struct pid *find_vpid(int nr)
347{ 347{
348 return find_pid_ns(nr, current->nsproxy->pid_ns); 348 return find_pid_ns(nr, task_active_pid_ns(current));
349} 349}
350EXPORT_SYMBOL_GPL(find_vpid); 350EXPORT_SYMBOL_GPL(find_vpid);
351 351
@@ -429,7 +429,7 @@ struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
429 429
430struct task_struct *find_task_by_vpid(pid_t vnr) 430struct task_struct *find_task_by_vpid(pid_t vnr)
431{ 431{
432 return find_task_by_pid_ns(vnr, current->nsproxy->pid_ns); 432 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
433} 433}
434 434
435struct pid *get_task_pid(struct task_struct *task, enum pid_type type) 435struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
@@ -484,7 +484,7 @@ EXPORT_SYMBOL_GPL(pid_nr_ns);
484 484
485pid_t pid_vnr(struct pid *pid) 485pid_t pid_vnr(struct pid *pid)
486{ 486{
487 return pid_nr_ns(pid, current->nsproxy->pid_ns); 487 return pid_nr_ns(pid, task_active_pid_ns(current));
488} 488}
489EXPORT_SYMBOL_GPL(pid_vnr); 489EXPORT_SYMBOL_GPL(pid_vnr);
490 490
@@ -495,7 +495,7 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
495 495
496 rcu_read_lock(); 496 rcu_read_lock();
497 if (!ns) 497 if (!ns)
498 ns = current->nsproxy->pid_ns; 498 ns = task_active_pid_ns(current);
499 if (likely(pid_alive(task))) { 499 if (likely(pid_alive(task))) {
500 if (type != PIDTYPE_PID) 500 if (type != PIDTYPE_PID)
501 task = task->group_leader; 501 task = task->group_leader;
diff --git a/kernel/signal.c b/kernel/signal.c
index 0af8868525d..b2445d86f22 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1752,7 +1752,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
1752 * see comment in do_notify_parent() about the following 4 lines 1752 * see comment in do_notify_parent() about the following 4 lines
1753 */ 1753 */
1754 rcu_read_lock(); 1754 rcu_read_lock();
1755 info.si_pid = task_pid_nr_ns(tsk, parent->nsproxy->pid_ns); 1755 info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(parent));
1756 info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk)); 1756 info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk));
1757 rcu_read_unlock(); 1757 rcu_read_unlock();
1758 1758
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 65bdcf198d4..5a638445050 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -1344,7 +1344,7 @@ static ssize_t binary_sysctl(const int *name, int nlen,
1344 goto out_putname; 1344 goto out_putname;
1345 } 1345 }
1346 1346
1347 mnt = current->nsproxy->pid_ns->proc_mnt; 1347 mnt = task_active_pid_ns(current)->proc_mnt;
1348 file = file_open_root(mnt->mnt_root, mnt, pathname, flags); 1348 file = file_open_root(mnt->mnt_root, mnt, pathname, flags);
1349 result = PTR_ERR(file); 1349 result = PTR_ERR(file);
1350 if (IS_ERR(file)) 1350 if (IS_ERR(file))