cpu_relax(), rep: nop, and PAUSE

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Tue Feb 19 16:41:48 EST 2013


On Wed, 20 Feb 2013 01:58:17 +0700, Mulyadi Santosa said:
> On Tue, Feb 19, 2013 at 7:20 PM, David Shwatrz <dshwatrz at gmail.com> 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 ?
>
> Just guessing, maybe rep+nop could do better power saving because
> processor is considered as idle.

The 'rep; nop' is actually a placeholder - for some CPUs, a different opcode
gets filled in during boot time.  See arch/x86/kernel/alternative.c and
arch/x86/include/asm/alternative.h for the gory details.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130219/a0c43ea8/attachment.bin 


More information about the Kernelnewbies mailing list