]> git.baikalelectronics.ru Git - kernel.git/commit
posix-cpu-timers: Store a reference to a pid not a task
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 28 Feb 2020 17:11:06 +0000 (11:11 -0600)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 4 Mar 2020 08:54:55 +0000 (09:54 +0100)
commitd58d6b25301cb4436b58d4d89a3a80fd54326cef
tree5ea233fd8cf97b66952b78d773595598ffc000bc
parent5535441440043510867a7ad1a5899b2d02cbfa31
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.

Fixes: 39778356bc72 ("posix-cpu-timers: workaround to suppress the problems with mt exec")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/87wo86tz6d.fsf@x220.int.ebiederm.org
include/linux/posix-timers.h
kernel/time/posix-cpu-timers.c