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@xxxxxxxxx> --- 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