]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm/syscalls: mark syscall invocation as likely in invoke_syscall
authorCan Peng <pengcan@kylinos.cn>
Fri, 19 Sep 2025 10:00:42 +0000 (18:00 +0800)
committerWill Deacon <will@kernel.org>
Mon, 22 Sep 2025 12:26:16 +0000 (13:26 +0100)
The invoke_syscall() function is overwhelmingly called for
valid system call entries. Annotate the main path with likely()
to help the compiler generate better branch prediction hints,
reducing CPU pipeline stalls due to mispredictions.

This is a micro-optimization targeting syscall-heavy workloads [1].

Link: https://lore.kernel.org/r/20250922121730.986761-1-pengcan@kylinos.cn
Signed-off-by: Can Peng <pengcan@kylinos.cn>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/syscall.c

index c442fcec6b9e8ca59981aa8b440d00df167f21a3..aba7ca6bca2d1a1640458d241575facd7852c4c4 100644 (file)
@@ -43,7 +43,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno,
 
        add_random_kstack_offset();
 
-       if (scno < sc_nr) {
+       if (likely(scno < sc_nr)) {
                syscall_fn_t syscall_fn;
                syscall_fn = syscall_table[array_index_nospec(scno, sc_nr)];
                ret = __invoke_syscall(regs, syscall_fn);