* [PATCH] x86-64: adjust ia32entry branches for better static prediction
@ 2009-10-20 7:10 Jan Beulich
2009-10-20 7:21 ` Eric Dumazet
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2009-10-20 7:10 UTC (permalink / raw)
To: mingo, tglx, hpa; +Cc: linux-kernel
Swap branch pairs so that the static branch prediction logic would
consider the syscall-number-in-range case the taken path.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
---
arch/x86/ia32/ia32entry.S | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
--- linux-2.6.32-rc5/arch/x86/ia32/ia32entry.S 2009-10-19 13:12:43.000000000 +0200
+++ 2.6.32-rc5-x86_64-ia32-syscall-trace-branch-dir/arch/x86/ia32/ia32entry.S 2009-10-19 09:36:39.000000000 +0200
@@ -249,9 +249,9 @@ sysenter_tracesys:
call syscall_trace_enter
LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
RESTORE_REST
- cmpl $(IA32_NR_syscalls-1),%eax
- ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
- jmp sysenter_do_call
+ cmpl $IA32_NR_syscalls,%eax
+ jb sysenter_do_call
+ jmp int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
CFI_ENDPROC
ENDPROC(ia32_sysenter_target)
@@ -368,9 +368,9 @@ cstar_tracesys:
LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
RESTORE_REST
xchgl %ebp,%r9d
- cmpl $(IA32_NR_syscalls-1),%eax
- ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
- jmp cstar_do_call
+ cmpl $IA32_NR_syscalls,%eax
+ jb cstar_do_call
+ jmp int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
END(ia32_cstar_target)
ia32_badarg:
@@ -445,9 +445,9 @@ ia32_tracesys:
call syscall_trace_enter
LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
RESTORE_REST
- cmpl $(IA32_NR_syscalls-1),%eax
- ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
- jmp ia32_do_call
+ cmpl $IA32_NR_syscalls,%eax
+ jb ia32_do_call
+ jmp int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
END(ia32_syscall)
ia32_badsys:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86-64: adjust ia32entry branches for better static prediction
2009-10-20 7:10 [PATCH] x86-64: adjust ia32entry branches for better static prediction Jan Beulich
@ 2009-10-20 7:21 ` Eric Dumazet
2009-10-20 7:24 ` H. Peter Anvin
0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2009-10-20 7:21 UTC (permalink / raw)
To: Jan Beulich; +Cc: mingo, tglx, hpa, linux-kernel
Jan Beulich a écrit :
> Swap branch pairs so that the static branch prediction logic would
> consider the syscall-number-in-range case the taken path.
>
> Signed-off-by: Jan Beulich <jbeulich@novell.com>
>
> ---
> arch/x86/ia32/ia32entry.S | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> --- linux-2.6.32-rc5/arch/x86/ia32/ia32entry.S 2009-10-19 13:12:43.000000000 +0200
> +++ 2.6.32-rc5-x86_64-ia32-syscall-trace-branch-dir/arch/x86/ia32/ia32entry.S 2009-10-19 09:36:39.000000000 +0200
> @@ -249,9 +249,9 @@ sysenter_tracesys:
> call syscall_trace_enter
> LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
> RESTORE_REST
> - cmpl $(IA32_NR_syscalls-1),%eax
> - ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
> - jmp sysenter_do_call
> + cmpl $IA32_NR_syscalls,%eax
> + jb sysenter_do_call
> + jmp int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
> CFI_ENDPROC
on cmov enabled build, we could use cmov instruction to load eax with number
that calls enosys_syscall(), to avoid loading -ENOSYS,RAX
and these branches...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86-64: adjust ia32entry branches for better static prediction
2009-10-20 7:21 ` Eric Dumazet
@ 2009-10-20 7:24 ` H. Peter Anvin
2009-10-26 8:28 ` Andi Kleen
0 siblings, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2009-10-20 7:24 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Jan Beulich, mingo, tglx, linux-kernel
On 10/20/2009 04:21 PM, Eric Dumazet wrote:
>>
>> --- linux-2.6.32-rc5/arch/x86/ia32/ia32entry.S 2009-10-19 13:12:43.000000000 +0200
>> +++ 2.6.32-rc5-x86_64-ia32-syscall-trace-branch-dir/arch/x86/ia32/ia32entry.S 2009-10-19 09:36:39.000000000 +0200
>> @@ -249,9 +249,9 @@ sysenter_tracesys:
>> call syscall_trace_enter
>> LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
>> RESTORE_REST
>> - cmpl $(IA32_NR_syscalls-1),%eax
>> - ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
>> - jmp sysenter_do_call
>> + cmpl $IA32_NR_syscalls,%eax
>> + jb sysenter_do_call
>> + jmp int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
>> CFI_ENDPROC
>
> on cmov enabled build, we could use cmov instruction to load eax with number
> that calls enosys_syscall(), to avoid loading -ENOSYS,RAX
> and these branches...
>
It's x86-64, cmov is guaranteed.
-hpa
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86-64: adjust ia32entry branches for better static prediction
2009-10-20 7:24 ` H. Peter Anvin
@ 2009-10-26 8:28 ` Andi Kleen
0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2009-10-26 8:28 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Eric Dumazet, Jan Beulich, mingo, tglx, linux-kernel
"H. Peter Anvin" <hpa@zytor.com> writes:
> On 10/20/2009 04:21 PM, Eric Dumazet wrote:
>>>
>>> --- linux-2.6.32-rc5/arch/x86/ia32/ia32entry.S 2009-10-19 13:12:43.000000000 +0200
>>> +++ 2.6.32-rc5-x86_64-ia32-syscall-trace-branch-dir/arch/x86/ia32/ia32entry.S 2009-10-19 09:36:39.000000000 +0200
>>> @@ -249,9 +249,9 @@ sysenter_tracesys:
>>> call syscall_trace_enter
>>> LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
>>> RESTORE_REST
>>> - cmpl $(IA32_NR_syscalls-1),%eax
>>> - ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
>>> - jmp sysenter_do_call
>>> + cmpl $IA32_NR_syscalls,%eax
>>> + jb sysenter_do_call
>>> + jmp int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
>>> CFI_ENDPROC
>>
>> on cmov enabled build, we could use cmov instruction to load eax with number
>> that calls enosys_syscall(), to avoid loading -ENOSYS,RAX
>> and these branches...
>>
>
> It's x86-64, cmov is guaranteed.
But it's also not necessarily faster.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-26 8:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-20 7:10 [PATCH] x86-64: adjust ia32entry branches for better static prediction Jan Beulich
2009-10-20 7:21 ` Eric Dumazet
2009-10-20 7:24 ` H. Peter Anvin
2009-10-26 8:28 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).