6

Does there exist an equivalent of the x86 PAUSE instruction, which is placed within busy waiting loops to improve performance, particularly on SMT machines, on PowerPC?

10

In the Linux kernel we have this in arch/powerpc/include/asm/processor.h

/* Macros for adjusting thread priority (hardware multi-threading) */
#define HMT_very_low()   asm volatile("or 31,31,31   # very low priority")
#define HMT_low()    asm volatile("or 1,1,1      # low priority")
#define HMT_medium_low() asm volatile("or 6,6,6      # medium low priority")
#define HMT_medium()     asm volatile("or 2,2,2      # medium priority")
#define HMT_medium_high() asm volatile("or 5,5,5      # medium high priority")
#define HMT_high()   asm volatile("or 3,3,3      # high priority")

I'm not familiar with x86 PAUSE, but sounds like "or 31,31,31" is what you want.

Which powerpc processor are you doing this on? For SMT it must be POWER5, 6 or 7?

4

The PowerPC inside of Cell will recognize certain NOP encodings as indication to adjust the relative priority of the two physical threads in the core. The documentation lists the cctpl, cctpm, and cctph extended mnemonics for these special NOPs.

From the look of other Google results, it looks like perhaps the IBM RS64 line had similar special NOP instructions, so this functionality has probably been in "Book IV" of various IBM PowerPC chips for quite some time.

The Power ISA 2.06 document has additional special NOP definitions in chapter 3 with extended mnemonics like yield, mdoio, and mdoom. It also defines the same NOPs as cctpl and cctpm from Cell.

4

enter image description here

  • It'd be better to reproduce this in text to guard against link rot. – user195488 Sep 29 '11 at 12:17
  • @0A0D, actually, he's using imgur which is what SO uses for an image server, so it should never see linkrot. – Lance Roberts Sep 29 '11 at 17:44
  • @LanceRoberts: Fair enough. I just used Firebug to inspect the element and saw it is using imgur. – user195488 Sep 29 '11 at 17:48
  • @0A0d, you can just hit the edit link and see the link for the image also. – Lance Roberts Sep 29 '11 at 17:49
  • 1
    The accepted answer is correct but it lacks the explanations about what those magical numbers do. Plus the code itself is GPL. So you better ignore it and use information that I pasted directly from IBM documentation. P.S mdoom -- awesome mnemonics ;-) – Iouri Goussev Sep 30 '11 at 2:01

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.