Skip to content

Commit b9ee31e

Browse files
npigginmpe
authored andcommitted
powerpc/64s/idle: POWER9 ESL=0 stop avoid save/restore overhead
When stop is executed with EC=ESL=0, it appears to execute like a normal instruction (resuming from NIP when woken by interrupt). So all the save/restore handling can be avoided completely. In particular NV GPRs do not have to be saved, and MSR does not have to be switched back to kernel MSR. So move the test for EC=ESL=0 sleep states out to power9_idle_stop, and return directly to the caller after stop in that case. This improves performance for ping-pong benchmark with the stop0_lite idle state by 2.54% for 2 threads in the same core, and 2.57% for different cores. Performance increase with HV_POSSIBLE defined will be improved further by avoiding the hwsync. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent d0b791c commit b9ee31e

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

arch/powerpc/kernel/idle_book3s.S

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -324,32 +324,8 @@ enter_winkle:
324324
/*
325325
* r3 - PSSCR value corresponding to the requested stop state.
326326
*/
327-
power_enter_stop:
328-
/*
329-
* Check if we are executing the lite variant with ESL=EC=0
330-
*/
331-
andis. r4,r3,PSSCR_EC_ESL_MASK_SHIFTED
327+
power_enter_stop_esl:
332328
clrldi r3,r3,60 /* r3 = Bits[60:63] = Requested Level (RL) */
333-
bne .Lhandle_esl_ec_set
334-
PPC_STOP
335-
li r3,0 /* Since we didn't lose state, return 0 */
336-
std r3, PACA_REQ_PSSCR(r13)
337-
338-
/*
339-
* pnv_wakeup_noloss() expects r12 to contain the SRR1 value so
340-
* it can determine if the wakeup reason is an HMI in
341-
* CHECK_HMI_INTERRUPT.
342-
*
343-
* However, when we wakeup with ESL=0, SRR1 will not contain the wakeup
344-
* reason, so there is no point setting r12 to SRR1.
345-
*
346-
* Further, we clear r12 here, so that we don't accidentally enter the
347-
* HMI in pnv_wakeup_noloss() if the value of r12[42:45] == WAKE_HMI.
348-
*/
349-
li r12, 0
350-
b pnv_wakeup_noloss
351-
352-
.Lhandle_esl_ec_set:
353329
BEGIN_FTR_SECTION
354330
/*
355331
* POWER9 DD2.0 or earlier can incorrectly set PMAO when waking up after
@@ -441,21 +417,32 @@ _GLOBAL(power9_offline_stop)
441417
/* fall through */
442418

443419
_GLOBAL(power9_idle_stop)
420+
mtspr SPRN_PSSCR,r3
421+
/*
422+
* The ESL=EC=0 case does not wake up at 0x100, and it does not
423+
* allow SMT mode switching, so it does not require PSSCR to be
424+
* saved.
425+
*/
426+
andis. r4,r3,PSSCR_EC_ESL_MASK_SHIFTED
427+
bne 1f
428+
PPC_STOP
429+
li r3,0 /* Since we didn't lose state, return 0 */
430+
blr
431+
1:
444432
std r3, PACA_REQ_PSSCR(r13)
445433
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
446434
BEGIN_FTR_SECTION
447435
sync
448436
lwz r5, PACA_DONT_STOP(r13)
449437
cmpwi r5, 0
450-
bne 1f
438+
bne 2f
451439
END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_XER_SO_BUG)
452440
#endif
453-
mtspr SPRN_PSSCR,r3
454-
LOAD_REG_ADDR(r4,power_enter_stop)
441+
LOAD_REG_ADDR(r4,power_enter_stop_esl)
455442
b pnv_powersave_common
456443
/* No return */
457444
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
458-
1:
445+
2:
459446
/*
460447
* We get here when TM / thread reconfiguration bug workaround
461448
* code wants to get the CPU into SMT4 mode, and therefore

0 commit comments

Comments
 (0)