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>
This commit is contained in:
@@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
|
||||
|
||||
struct pid *find_vpid(int nr)
|
||||
{
|
||||
return find_pid_ns(nr, current->nsproxy->pid_ns);
|
||||
return find_pid_ns(nr, task_active_pid_ns(current));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(find_vpid);
|
||||
|
||||
@@ -429,7 +429,7 @@ struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
|
||||
|
||||
struct task_struct *find_task_by_vpid(pid_t vnr)
|
||||
{
|
||||
return find_task_by_pid_ns(vnr, current->nsproxy->pid_ns);
|
||||
return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
|
||||
}
|
||||
|
||||
struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
|
||||
@@ -484,7 +484,7 @@ EXPORT_SYMBOL_GPL(pid_nr_ns);
|
||||
|
||||
pid_t pid_vnr(struct pid *pid)
|
||||
{
|
||||
return pid_nr_ns(pid, current->nsproxy->pid_ns);
|
||||
return pid_nr_ns(pid, task_active_pid_ns(current));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pid_vnr);
|
||||
|
||||
@@ -495,7 +495,7 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
|
||||
|
||||
rcu_read_lock();
|
||||
if (!ns)
|
||||
ns = current->nsproxy->pid_ns;
|
||||
ns = task_active_pid_ns(current);
|
||||
if (likely(pid_alive(task))) {
|
||||
if (type != PIDTYPE_PID)
|
||||
task = task->group_leader;
|
||||
|
Reference in New Issue
Block a user