History

posix-cpu-timers: Store a reference to a pid not a task

posix cpu timers do not handle the death of a process well. This is most clearly seen when a multi-threaded process calls exec from a thread that is not the leader of the thread group. The posix cpu timer code continues to pin the old thread group leader and is unable to find the siglock from there. This results in posix_cpu_timer_del being unable to delete a timer, posix_cpu_timer_set being unable to set a timer. Further to compensate for the problems in posix_cpu_timer_del on a multi-threaded exec all timers that point at the multi-threaded task are stopped. The code for the timers fundamentally needs to check if the target process/thread is alive. This needs an extra level of indirection. This level of indirection is already available in struct pid. So replace cpu.task with cpu.pid to get the needed extra layer of indirection. In addition to handling things more cleanly this reduces the amount of memory a timer can pin when a process exits and then is reaped from a task_struct to the vastly smaller struct pid.

Eric W. Biederman committed 6 years ago

Commit 55e8c8e1 parent beb41d92 files · +56 −19Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/posix-timers.h+1−1
@@ -69,7 +69,7 @@ static inline int clockid_to_fd(const clockid_t clk) · 68 unmodified lines
6969 struct cpu_timer {
7070 struct timerqueue_node node;
7171 struct timerqueue_head *head;
72− struct task_struct *task;
72+ struct pid *pid;
7373 struct list_head elist;
7474 int firing;
7575 };