cpu_relax(), rep: nop, and PAUSE

Adam Lee adam8157 at gmail.com
Tue Feb 19 22:35:42 EST 2013


On Tue, Feb 19, 2013 at 02:20:11PM +0200, David Shwatrz wrote:
> Hi, kernel newbies,
> 
> We have:
> #define cpu_relax()	asm volatile("rep; nop")
> in arch/x86/boot/boot.h.
> 
> Why don't we use the PAUSE assembler instruction here ?

But rep_nop and pause ought to be the same, why we change it? "If it
ain't broke, don't fix it."

You can see that by disassembling, they both are "f3 90", "f3" is rep,
"90" is nop.

> And AFAIK, in spinlocks , PAUSE indeed replaced the rep;nop.

Where? I haven't found that.

-- 
Regards,
Adam Lee
http://adam8157.info



More information about the Kernelnewbies mailing list