Using x86 pause instr in SpinPause
Eric Caspole
eric.caspole at amd.com
Tue Aug 28 08:36:23 PDT 2012
Hi everybody,
I have made a webrev making a one-line change to remove use of PAUSE
in linux x64. This will bring linux into sync with windows where
SpinPause is just "return 0" as Dan indicates below.
http://cr.openjdk.java.net/~ecaspole/nopause/webrev.00/webrev/
We find that it is better not to use PAUSE in this kind of spin
routine. Apparently someone discovered that on windows x64 years ago.
Thanks,
Eric
On Aug 16, 2012, at 5:07 PM, Daniel D. Daugherty wrote:
> On Win64, SpinPause() has been "return 0" since mid-2005. Way back
> when Win64 code was in os_win32_amd64.cpp:
>
> SCCS/s.os_win32_amd64.cpp:
>
> D 1.9.1.1 05/07/04 03:20:45 dice 12 10 00025/00000/00334
> MRs:
> COMMENTS:
> 5030359 -- back-end synchonization improvements - adaptive
> spinning, etc
>
> When the i486 and amd64 cpu dirs were merged back in 2007, the code
> became like it is below (#ifdef'ed):
>
> D 1.32 07/09/17 09:11:33 sgoldman 37 35 00264/00008/00218
> MRs:
> COMMENTS:
> 5108146 Merge i486 and amd64 cpu directories.
> Macro-ized register names. Inserted amd64 specific code.
>
> Looks like on Linux-X64, the code has used the PAUSE instruction
> since mid-2005:
>
> D 1.3 05/07/04 03:14:09 dice 4 3 00031/00000/00353
> MRs:
> COMMENTS:
> 5030359 -- back-end synchonization improvements - adaptive
> spinning, etc
>
> We'll have to see if Dave Dice remember why he implemented
> it this way...
>
> Dan
>
>
> On 8/16/12 12:01 PM, Eric Caspole wrote:
>> Hi everybody,
>> Does anybody know the reason why SpinPause is simply "return 0" on
>> Win64 but uses PAUSE on Linux in a .s file?
>> We would like to remove PAUSE from linux too.
>>
>> Thanks,
>> Eric
>>
>>
>> ./src/os_cpu/windows_x86/vm/os_windows_x86.cpp
>>
>> 548 extern "C" int SpinPause () {
>> 549 #ifdef AMD64
>> 550 return 0 ;
>> 551 #else
>> 552 // pause == rep:nop
>> 553 // On systems that don't support pause a rep:nop
>> 554 // is executed as a nop. The rep: prefix is ignored.
>> 555 _asm {
>> 556 pause ;
>> 557 };
>> 558 return 1 ;
>> 559 #endif // AMD64
>> 560 }
>>
>>
>> src/os_cpu/linux_x86/vm/linux_x86_64.s
>>
>> 63 .globl SpinPause
>> 64 .align 16
>> 65 .type SpinPause, at function
>> 66 SpinPause:
>> 67 rep
>> 68 nop
>> 69 movq $1, %rax
>> 70 ret
>>
>>
>
More information about the hotspot-runtime-dev
mailing list