lkml.org 
[lkml]   [2021]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 3/4] tools headers UAPI: add cpu_relax() implementation for x86 and arm64
From
Date
On 2021/7/22 4:53, David Laight wrote:
> From: Yunsheng Lin
>> Sent: 20 July 2021 03:22
>>
>> As x86 and arm64 is the two available systems that I can build
>> and test the cpu_relax() implementation, so only add cpu_relax()
>> implementation for x86 and arm64, other arches can be added easily
>> when needed.
>>
> ...
>> +#if defined(__i386__) || defined(__x86_64__)
>> +/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
>> +static __always_inline void rep_nop(void)
>> +{
>> + asm volatile("rep; nop" ::: "memory");
>> +}
>
> Beware, Intel increased the stall for 'rep nop' in some recent
> cpu to IIRC about 200 cycles.
>
> They even document that this might have a detrimental effect.
> It is basically far too long for the sort of thing it makes
> sense to busy-wait for.

Thanks for the info:)
I will be beware of that when playing with 'rep nop' in newer
x86 cpu.

> .
>

\
 
 \ /
  Last update: 2021-07-22 19:14    [W:0.929 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site