public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* SMP Pentium4 -- PAUSE Instruction
@ 2002-12-03 15:42 Calin A. Culianu
  2002-12-03 15:55 ` Dave Jones
  2002-12-03 16:06 ` Arjan van de Ven
  0 siblings, 2 replies; 5+ messages in thread
From: Calin A. Culianu @ 2002-12-03 15:42 UTC (permalink / raw)
  To: Linux Kernel Mailing List


I as wondering -- according to Intel's docs they recommend that on a P4
processor to use the PAUSE instruction (aka rep followed by a nop) inside
any spin loop (such as one used in SMP spinlock code) in order to both
improve processor performance and reduce power consumption.

Is this instruction being used in spin-wait loops?  For some reason, I am
having a hard time figuring out whether or not it is being used.  There is
a rep_nop() in processor.h.. but I can't determine if that is being called
for spin lock lock/unlock code.


-Calin



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SMP Pentium4 -- PAUSE Instruction
  2002-12-03 15:42 SMP Pentium4 -- PAUSE Instruction Calin A. Culianu
@ 2002-12-03 15:55 ` Dave Jones
  2002-12-03 16:06 ` Arjan van de Ven
  1 sibling, 0 replies; 5+ messages in thread
From: Dave Jones @ 2002-12-03 15:55 UTC (permalink / raw)
  To: Calin A. Culianu; +Cc: Linux Kernel Mailing List

On Tue, Dec 03, 2002 at 10:42:13AM -0500, Calin A. Culianu wrote:
 > 
 > I as wondering -- according to Intel's docs they recommend that on a P4
 > processor to use the PAUSE instruction (aka rep followed by a nop) inside
 > any spin loop (such as one used in SMP spinlock code) in order to both
 > improve processor performance and reduce power consumption.
 > Is this instruction being used in spin-wait loops?  For some reason, I am
 > having a hard time figuring out whether or not it is being used.  There is
 > a rep_nop() in processor.h.. but I can't determine if that is being called
 > for spin lock lock/unlock code.

there's also rep;nop in asm-i386/spinlock.h
See spin_lock_string()

		Dave

-- 
| Dave Jones.        http://www.codemonkey.org.uk
| SuSE Labs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: SMP Pentium4 -- PAUSE Instruction
@ 2002-12-03 15:57 Nakajima, Jun
  0 siblings, 0 replies; 5+ messages in thread
From: Nakajima, Jun @ 2002-12-03 15:57 UTC (permalink / raw)
  To: Calin A. Culianu, Linux Kernel Mailing List

That one is for tight loops. Spin locks are inlined, and PAUSE is used like:

#define spin_lock_string \
        "\n1:\t" \
        "lock ; decb %0\n\t" \
        "js 2f\n" \
        LOCK_SECTION_START("") \
        "2:\t" \
        "cmpb $0,%0\n\t" \
        "rep;nop\n\t" \ <---
        "jle 2b\n\t" \
        "jmp 1b\n" \
        LOCK_SECTION_END

Also take a look at arch/i386/kernel/semaphore.c for read/write_locks.

Jun

> -----Original Message-----
> From: Calin A. Culianu [mailto:calin@ajvar.org]
> Sent: Tuesday, December 03, 2002 7:42 AM
> To: Linux Kernel Mailing List
> Subject: SMP Pentium4 -- PAUSE Instruction
> 
> 
> I as wondering -- according to Intel's docs they recommend that on a P4
> processor to use the PAUSE instruction (aka rep followed by a nop) inside
> any spin loop (such as one used in SMP spinlock code) in order to both
> improve processor performance and reduce power consumption.
> 
> Is this instruction being used in spin-wait loops?  For some reason, I am
> having a hard time figuring out whether or not it is being used.  There is
> a rep_nop() in processor.h.. but I can't determine if that is being called
> for spin lock lock/unlock code.
> 
> 
> -Calin
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SMP Pentium4 -- PAUSE Instruction
  2002-12-03 15:42 SMP Pentium4 -- PAUSE Instruction Calin A. Culianu
  2002-12-03 15:55 ` Dave Jones
@ 2002-12-03 16:06 ` Arjan van de Ven
  2002-12-03 17:21   ` Calin A. Culianu
  1 sibling, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2002-12-03 16:06 UTC (permalink / raw)
  To: Calin A. Culianu; +Cc: Linux Kernel Mailing List

On Tue, 2002-12-03 at 16:42, Calin A. Culianu wrote:

> Is this instruction being used in spin-wait loops?  For some reason, I am
> having a hard time figuring out whether or not it is being used.  There is
> a rep_nop() in processor.h.. but I can't determine if that is being called
> for spin lock lock/unlock code.

check cpu_relax() all over the kernel :)
and the spinlock code uses it inside it's own asm directly, not via
rep_nop()



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: SMP Pentium4 -- PAUSE Instruction
  2002-12-03 16:06 ` Arjan van de Ven
@ 2002-12-03 17:21   ` Calin A. Culianu
  0 siblings, 0 replies; 5+ messages in thread
From: Calin A. Culianu @ 2002-12-03 17:21 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: Linux Kernel Mailing List


:)  Oh.  Don't I feel like I hit the panic button too early... :/

-Calin

On 3 Dec 2002, Arjan van de Ven wrote:

> On Tue, 2002-12-03 at 16:42, Calin A. Culianu wrote:
>
> > Is this instruction being used in spin-wait loops?  For some reason, I am
> > having a hard time figuring out whether or not it is being used.  There is
> > a rep_nop() in processor.h.. but I can't determine if that is being called
> > for spin lock lock/unlock code.
>
> check cpu_relax() all over the kernel :)
> and the spinlock code uses it inside it's own asm directly, not via
> rep_nop()
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-12-03 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-03 15:42 SMP Pentium4 -- PAUSE Instruction Calin A. Culianu
2002-12-03 15:55 ` Dave Jones
2002-12-03 16:06 ` Arjan van de Ven
2002-12-03 17:21   ` Calin A. Culianu
  -- strict thread matches above, loose matches on Subject: below --
2002-12-03 15:57 Nakajima, Jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox