Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Removing has_group_leader_pid

With de_thread now calling exchange_tids has_group_leader_pid no longer
makes any sense and is equivalent to calling thread_group_leader.

As there are only 2 remaining users of has_group_leader_pid let's
update the code and get rid of has_group_leader_pid.

There is one extra patch to lookup_task that performs that unifies
to code paths that become identical when has_group_leader_pid went
away.

Eric W. Biederman (4):
posix-cpu-timer: Tidy up group_leader logic in lookup_task
posix-cpu-timer: Unify the now redundant code in lookup_task
exec: Remove BUG_ON(has_group_leader_pid)
signal: Remove has_group_leader_pid

fs/exec.c | 1 -
include/linux/sched/signal.h | 11 -----------
kernel/time/posix-cpu-timers.c | 21 ++++++++-------------
3 files changed, 8 insertions(+), 25 deletions(-)

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+8 -25
-1
fs/exec.c
··· 1176 1176 tsk->start_boottime = leader->start_boottime; 1177 1177 1178 1178 BUG_ON(!same_thread_group(leader, tsk)); 1179 - BUG_ON(has_group_leader_pid(tsk)); 1180 1179 /* 1181 1180 * An exec() starts a new thread group with the 1182 1181 * TGID of the previous thread group. Rehash the
-11
include/linux/sched/signal.h
··· 654 654 return p->exit_signal >= 0; 655 655 } 656 656 657 - /* Do to the insanities of de_thread it is possible for a process 658 - * to have the pid of the thread group leader without actually being 659 - * the thread group leader. For iteration through the pids in proc 660 - * all we care about is that we have a task with the appropriate 661 - * pid, we don't actually care if we have the right task. 662 - */ 663 - static inline bool has_group_leader_pid(struct task_struct *p) 664 - { 665 - return task_pid(p) == task_tgid(p); 666 - } 667 - 668 657 static inline 669 658 bool same_thread_group(struct task_struct *p1, struct task_struct *p2) 670 659 {
+8 -13
kernel/time/posix-cpu-timers.c
··· 66 66 if (thread) 67 67 return same_thread_group(p, current) ? p : NULL; 68 68 69 - if (gettime) { 70 - /* 71 - * For clock_gettime(PROCESS) the task does not need to be 72 - * the actual group leader. tsk->sighand gives 73 - * access to the group's clock. 74 - * 75 - * Timers need the group leader because they take a 76 - * reference on it and store the task pointer until the 77 - * timer is destroyed. 78 - */ 79 - return (p == current || thread_group_leader(p)) ? p : NULL; 80 - } 69 + /* 70 + * For clock_gettime(PROCESS) the task does not need to be 71 + * the actual group leader. task->signal gives 72 + * access to the group's clock. 73 + */ 74 + if (gettime && (p == current)) 75 + return p; 81 76 82 77 /* 83 78 * For processes require that p is group leader. 84 79 */ 85 - return has_group_leader_pid(p) ? p : NULL; 80 + return thread_group_leader(p) ? p : NULL; 86 81 } 87 82 88 83 static struct task_struct *__get_task_for_clock(const clockid_t clock,