Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17cf22c3 authored by Eric W. Biederman's avatar Eric W. Biederman
Browse files

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: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 49f4d8b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1094,7 +1094,7 @@ static int show_spu_loadavg(struct seq_file *s, void *private)
		LOAD_INT(c), LOAD_FRAC(c),
		count_active_contexts(),
		atomic_read(&nr_spu_contexts),
		current->nsproxy->pid_ns->last_pid);
		task_active_pid_ns(current)->last_pid);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ void mconsole_log(struct mc_request *req)

void mconsole_proc(struct mc_request *req)
{
	struct vfsmount *mnt = current->nsproxy->pid_ns->proc_mnt;
	struct vfsmount *mnt = task_active_pid_ns(current)->proc_mnt;
	char *buf;
	int len;
	struct file *file;
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/pid_namespace.h>

#include "binder.h"

@@ -2344,7 +2345,7 @@ static int binder_thread_read(struct binder_proc *proc,
		if (t->from) {
			struct task_struct *sender = t->from->proc->tsk;
			tr.sender_pid = task_tgid_nr_ns(sender,
							current->nsproxy->pid_ns);
							task_active_pid_ns(current));
		} else {
			tr.sender_pid = 0;
		}
+1 −1
Original line number Diff line number Diff line
@@ -710,7 +710,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
	struct vfsmount *proc_mnt;
	int err = -ENOENT;

	proc_mnt = mntget(current->nsproxy->pid_ns->proc_mnt);
	proc_mnt = mntget(task_active_pid_ns(current)->proc_mnt);
	if (IS_ERR(proc_mnt))
		goto out;

+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ static struct dentry *proc_mount(struct file_system_type *fs_type,
		ns = (struct pid_namespace *)data;
		options = NULL;
	} else {
		ns = current->nsproxy->pid_ns;
		ns = task_active_pid_ns(current);
		options = data;
	}

Loading