Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

signal: avoid clearing TIF_SIGPENDING in recalc_sigpending() if unset

Clearing is an atomic op and the flag is not set most of the time.

When creating and destroying threads in the same process with the pthread
family, the primary bottleneck is calls to sigprocmask which take the
process-wide sighand lock.

Avoiding the atomic gives me a 2% bump in start/teardown rate at 24-core
scale.

[akpm@linux-foundation.org: add unlikely() as well]
Link: https://lkml.kernel.org/r/20250303134908.423242-1-mjguzik@gmail.com
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mateusz Guzik and committed by
Andrew Morton
8a56f266 e0349c46

+4 -3
+4 -3
kernel/signal.c
··· 176 176 177 177 void recalc_sigpending(void) 178 178 { 179 - if (!recalc_sigpending_tsk(current) && !freezing(current)) 180 - clear_thread_flag(TIF_SIGPENDING); 181 - 179 + if (!recalc_sigpending_tsk(current) && !freezing(current)) { 180 + if (unlikely(test_thread_flag(TIF_SIGPENDING))) 181 + clear_thread_flag(TIF_SIGPENDING); 182 + } 182 183 } 183 184 EXPORT_SYMBOL(recalc_sigpending); 184 185