Skip to content

Commit 8feebc6

Browse files
committed
posix-cpu-timer: Tidy up group_leader logic in lookup_task
Replace has_group_leader_pid with thread_group_leader. Years ago Oleg suggested changing thread_group_leader to has_group_leader_pid to handle races. Looking at the code then and now I don't see how it ever helped. Especially as then the code really did need to be the thread_group_leader. Today it doesn't make a difference if thread_group_leader races with de_thread as the task returned from lookup_task in the non-thread case is just used to find values in task->signal. Since the races with de_thread have never been handled revert has_group_header_pid to thread_group_leader for clarity. Update the comment in lookup_task to remove implementation details that are no longer true and to mention task->signal instead of task->sighand, as the relevant cpu timer details are all in task->signal. Ref: 55e8c8e ("posix-cpu-timers: Store a reference to a pid not a task") Ref: c0deae8 ("posix-cpu-timers: Rcu_read_lock/unlock protect find_task_by_vpid call") Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 5071228 commit 8feebc6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

kernel/time/posix-cpu-timers.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,16 @@ static struct task_struct *lookup_task(const pid_t pid, bool thread,
6969
if (gettime) {
7070
/*
7171
* For clock_gettime(PROCESS) the task does not need to be
72-
* the actual group leader. tsk->sighand gives
72+
* the actual group leader. task->signal gives
7373
* 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.
7874
*/
7975
return (p == current || thread_group_leader(p)) ? p : NULL;
8076
}
8177

8278
/*
8379
* For processes require that p is group leader.
8480
*/
85-
return has_group_leader_pid(p) ? p : NULL;
81+
return thread_group_leader(p) ? p : NULL;
8682
}
8783

8884
static struct task_struct *__get_task_for_clock(const clockid_t clock,

0 commit comments

Comments
 (0)