]> git.itanic.dy.fi Git - linux-stable/commit
posix-timers: Prefer delivery of signals to the current thread
authorDmitry Vyukov <dvyukov@google.com>
Thu, 16 Mar 2023 12:30:27 +0000 (13:30 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 16 Apr 2023 07:00:18 +0000 (09:00 +0200)
commitbcb7ee79029dcaeb09668a4d1489de256829a7cc
tree6aaa05bb6b1e428283e64921a9012bbab4e8c0ed
parentaff69273af61f5d1c8fb401d6f19148d11629b41
posix-timers: Prefer delivery of signals to the current thread

POSIX timers using the CLOCK_PROCESS_CPUTIME_ID clock prefer the main
thread of a thread group for signal delivery. However, this has a
significant downside: it requires waking up a potentially idle thread.

Instead, prefer to deliver signals to the current thread (in the same
thread group) if SIGEV_THREAD_ID is not set by the user. This does not
change guaranteed semantics, since POSIX process CPU time timers have
never guaranteed that signal delivery is to a specific thread (without
SIGEV_THREAD_ID set).

The effect is that queueing the signal no longer wakes up potentially idle
threads, and the kernel is no longer biased towards delivering the timer
signal to any particular thread (which better distributes the timer signals
esp. when multiple timers fire concurrently).

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230316123028.2890338-1-elver@google.com
kernel/signal.c