public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall
@ 2025-09-19 10:00 Can Peng
  2025-09-19 11:40 ` Will Deacon
  2025-09-22 13:14 ` [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall Will Deacon
  0 siblings, 2 replies; 4+ messages in thread
From: Can Peng @ 2025-09-19 10:00 UTC (permalink / raw)
  To: catalin.marinas, will; +Cc: linux-arm-kernel, linux-kernel, Can Peng

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.

Signed-off-by: Can Peng <pengcan@kylinos.cn>
---
 arch/arm64/kernel/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
index c442fcec6b9e..aba7ca6bca2d 100644
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -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);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall
  2025-09-19 10:00 [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall Can Peng
@ 2025-09-19 11:40 ` Will Deacon
  2025-09-22 12:17   ` [PATCH 1/1] arm/syscalls: mark syscall invocation as Can Peng
  2025-09-22 13:14 ` [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall Will Deacon
  1 sibling, 1 reply; 4+ messages in thread
From: Will Deacon @ 2025-09-19 11:40 UTC (permalink / raw)
  To: Can Peng; +Cc: catalin.marinas, linux-arm-kernel, linux-kernel

On Fri, Sep 19, 2025 at 06:00:42PM +0800, Can Peng wrote:
> 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.

Does it actually make a measurable difference?

Will


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] arm/syscalls: mark syscall invocation as
  2025-09-19 11:40 ` Will Deacon
@ 2025-09-22 12:17   ` Can Peng
  0 siblings, 0 replies; 4+ messages in thread
From: Can Peng @ 2025-09-22 12:17 UTC (permalink / raw)
  To: catalin.marinas, will; +Cc: linux-arm-kernel, linux-kernel

Hello,

>> 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.
>
>Does it actually make a measurable difference?

This change implements a micro-optimization. Benchmark results
from the Kunpeng 920 machine are as follows:

before:
- lat_syscall result 
write call      0.2332  0.2337  0.2341
read call       0.2501  0.2493  0.2506

after:
- lat_syscall result
write call      0.2301  0.2316  0.2307
read call       0.2492  0.2498  0.2491


Best regards,
Can Peng


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall
  2025-09-19 10:00 [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall Can Peng
  2025-09-19 11:40 ` Will Deacon
@ 2025-09-22 13:14 ` Will Deacon
  1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2025-09-22 13:14 UTC (permalink / raw)
  To: catalin.marinas, Can Peng
  Cc: kernel-team, Will Deacon, linux-arm-kernel, linux-kernel

On Fri, 19 Sep 2025 18:00:42 +0800, Can Peng wrote:
> 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.
> 
> [...]

Applied to arm64 (for-next/entry), thanks!

[1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall
      https://git.kernel.org/arm64/c/da9e5c04be58

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-22 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-19 10:00 [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall Can Peng
2025-09-19 11:40 ` Will Deacon
2025-09-22 12:17   ` [PATCH 1/1] arm/syscalls: mark syscall invocation as Can Peng
2025-09-22 13:14 ` [PATCH 1/1] arm/syscalls: mark syscall invocation as likely in invoke_syscall Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox