cpu_relax(), rep: nop, and PAUSE

David Shwatrz dshwatrz at gmail.com
Tue Feb 19 07:20:11 EST 2013


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 ?

According to Intel manuals,
Intel® 64 and IA-32 Architectures
Software Developer’s Manual
Volume 2B:

"This instruction was introduced in the Pentium 4 processors, but is
backward compatible with all IA-32 processors.
In earlier IA-32 processors, the PAUSE instruction operates like a NOP
instruction. The Pentium 4 and Intel Xeon
processors implement the PAUSE instruction as a delay. The delay is
finite and can be zero for some processors.
This instruction does not change the architectural state of the
processor (that is, it performs essentially a delaying
no-op operation).
This instruction’s operation is the same in non-64-bit modes and 64-bit mode."

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

Any ideas?

Best,
DS



More information about the Kernelnewbies mailing list