Commit 06576edd authored by Eric W. Biederman's avatar Eric W. Biederman

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: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parents 50712280 bbd40fc4
...@@ -1176,7 +1176,6 @@ static int de_thread(struct task_struct *tsk) ...@@ -1176,7 +1176,6 @@ static int de_thread(struct task_struct *tsk)
tsk->start_boottime = leader->start_boottime; tsk->start_boottime = leader->start_boottime;
BUG_ON(!same_thread_group(leader, tsk)); BUG_ON(!same_thread_group(leader, tsk));
BUG_ON(has_group_leader_pid(tsk));
/* /*
* An exec() starts a new thread group with the * An exec() starts a new thread group with the
* TGID of the previous thread group. Rehash the * TGID of the previous thread group. Rehash the
......
...@@ -654,17 +654,6 @@ static inline bool thread_group_leader(struct task_struct *p) ...@@ -654,17 +654,6 @@ static inline bool thread_group_leader(struct task_struct *p)
return p->exit_signal >= 0; return p->exit_signal >= 0;
} }
/* Do to the insanities of de_thread it is possible for a process
* to have the pid of the thread group leader without actually being
* the thread group leader. For iteration through the pids in proc
* all we care about is that we have a task with the appropriate
* pid, we don't actually care if we have the right task.
*/
static inline bool has_group_leader_pid(struct task_struct *p)
{
return task_pid(p) == task_tgid(p);
}
static inline static inline
bool same_thread_group(struct task_struct *p1, struct task_struct *p2) bool same_thread_group(struct task_struct *p1, struct task_struct *p2)
{ {
......
...@@ -66,23 +66,18 @@ static struct task_struct *lookup_task(const pid_t pid, bool thread, ...@@ -66,23 +66,18 @@ static struct task_struct *lookup_task(const pid_t pid, bool thread,
if (thread) if (thread)
return same_thread_group(p, current) ? p : NULL; return same_thread_group(p, current) ? p : NULL;
if (gettime) {
/* /*
* For clock_gettime(PROCESS) the task does not need to be * For clock_gettime(PROCESS) the task does not need to be
* the actual group leader. tsk->sighand gives * the actual group leader. task->signal gives
* access to the group's clock. * access to the group's clock.
*
* Timers need the group leader because they take a
* reference on it and store the task pointer until the
* timer is destroyed.
*/ */
return (p == current || thread_group_leader(p)) ? p : NULL; if (gettime && (p == current))
} return p;
/* /*
* For processes require that p is group leader. * For processes require that p is group leader.
*/ */
return has_group_leader_pid(p) ? p : NULL; return thread_group_leader(p) ? p : NULL;
} }
static struct task_struct *__get_task_for_clock(const clockid_t clock, static struct task_struct *__get_task_for_clock(const clockid_t clock,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment