pids: Compute task_tgid using signal->leader_pid

The cost is the the same and this removes the need
to worry about complications that come from de_thread
and group_leader changing.

__task_pid_nr_ns has been updated to take advantage of this change.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
Eric W. Biederman
2017-09-26 12:45:33 -05:00
parent 1fb53567a3
commit 7a36094d61
9 changed files with 22 additions and 17 deletions

View File

@@ -421,13 +421,14 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
if (!ns)
ns = task_active_pid_ns(current);
if (likely(pid_alive(task))) {
if (type != PIDTYPE_PID) {
if (type == __PIDTYPE_TGID)
type = PIDTYPE_PID;
task = task->group_leader;
}
nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns);
struct pid *pid;
if (type == PIDTYPE_PID)
pid = task_pid(task);
else if (type == __PIDTYPE_TGID)
pid = task_tgid(task);
else
pid = rcu_dereference(task->group_leader->pids[type].pid);
nr = pid_nr_ns(pid, ns);
}
rcu_read_unlock();