aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-04-01 01:48:55 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2018-04-03 21:11:43 -0400
commitb9ee31e100e73075431faaf7af2ee0fbfd6e624b (patch)
treebcc182bc963d0d3c126c6046ba8c3562d3f9d908
parentd0b791c02994486b21fc48949ba276c72a88938d (diff)
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 <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/kernel/idle_book3s.S45
1 files changed, 16 insertions, 29 deletions
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index e5cb3eedb564..bc4e391d031e 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -324,32 +324,8 @@ enter_winkle:
324/* 324/*
325 * r3 - PSSCR value corresponding to the requested stop state. 325 * r3 - PSSCR value corresponding to the requested stop state.
326 */ 326 */
327power_enter_stop: 327power_enter_stop_esl:
328/*
329 * Check if we are executing the lite variant with ESL=EC=0
330 */
331 andis. r4,r3,PSSCR_EC_ESL_MASK_SHIFTED
332 clrldi r3,r3,60 /* r3 = Bits[60:63] = Requested Level (RL) */ 328 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:
353BEGIN_FTR_SECTION 329BEGIN_FTR_SECTION
354 /* 330 /*
355 * POWER9 DD2.0 or earlier can incorrectly set PMAO when waking up after 331 * POWER9 DD2.0 or earlier can incorrectly set PMAO when waking up after
@@ -441,21 +417,32 @@ _GLOBAL(power9_offline_stop)
441 /* fall through */ 417 /* fall through */
442 418
443_GLOBAL(power9_idle_stop) 419_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
4311:
444 std r3, PACA_REQ_PSSCR(r13) 432 std r3, PACA_REQ_PSSCR(r13)
445#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 433#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
446BEGIN_FTR_SECTION 434BEGIN_FTR_SECTION
447 sync 435 sync
448 lwz r5, PACA_DONT_STOP(r13) 436 lwz r5, PACA_DONT_STOP(r13)
449 cmpwi r5, 0 437 cmpwi r5, 0
450 bne 1f 438 bne 2f
451END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_XER_SO_BUG) 439END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_XER_SO_BUG)
452#endif 440#endif
453 mtspr SPRN_PSSCR,r3 441 LOAD_REG_ADDR(r4,power_enter_stop_esl)
454 LOAD_REG_ADDR(r4,power_enter_stop)
455 b pnv_powersave_common 442 b pnv_powersave_common
456 /* No return */ 443 /* No return */
457#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 444#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
4581: 4452:
459 /* 446 /*
460 * We get here when TM / thread reconfiguration bug workaround 447 * We get here when TM / thread reconfiguration bug workaround
461 * code wants to get the CPU into SMT4 mode, and therefore 448 * code wants to get the CPU into SMT4 mode, and therefore