* [PATCH][next] signal: improve performance of tgkill and do_rt_tgsigqueueinfo
@ 2025-02-12 16:07 Colin Ian King
0 siblings, 0 replies; only message in thread
From: Colin Ian King @ 2025-02-12 16:07 UTC (permalink / raw)
To: Thomas Gleixner, Peter Zijlstra; +Cc: kernel-janitors, linux-kernel
Adding an unlikely() hint on a couple of unlikely error return
paths improves run-time performance of tgkill and do_rt_tgsigqueueinfo.
Benchmarking on an i9-12900 shows an improvement of ~5% on a tgkill
on a process and ~3% improvement on sigqueue. Results based on running
20 tests and taking geometric mean of number of calls per second. Used
signal number 0 to check if process exists.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
kernel/signal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 081f19a24506..4ae848ce3a7a 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -4165,7 +4165,7 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig)
SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig)
{
/* This is only valid for single tasks */
- if (pid <= 0 || tgid <= 0)
+ if (unlikely(pid <= 0 || tgid <= 0))
return -EINVAL;
return do_tkill(tgid, pid, sig);
@@ -4233,7 +4233,7 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, kernel_siginfo_t *info)
{
/* This is only valid for single tasks */
- if (pid <= 0 || tgid <= 0)
+ if (unlikely(pid <= 0 || tgid <= 0))
return -EINVAL;
/* Not even root can pretend to send signals from the kernel.
--
2.47.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-02-12 16:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 16:07 [PATCH][next] signal: improve performance of tgkill and do_rt_tgsigqueueinfo Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®