diff mbox series

powerpc/64s: Fix doorbell wakeup msgclr optimisation

Message ID 20200402121212.1118218-1-npiggin@gmail.com (mailing list archive)
State Accepted
Commit 0c89649a70bed679fd408c1eb82fa99dbe1354a0
Headers show
Series powerpc/64s: Fix doorbell wakeup msgclr optimisation | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (d0c12846a3a24cd6d68b608c866712bc7e471634)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 fail build failed!
snowpatch_ozlabs/checkpatch warning total: 1 errors, 0 warnings, 0 checks, 22 lines checked
snowpatch_ozlabs/needsstable success Patch fixes a commit that hasn't been released yet

Commit Message

Nicholas Piggin April 2, 2020, 12:12 p.m. UTC
Commit 3282a3da25bd ("powerpc/64: Implement soft interrupt replay in C")
broke the doorbell wakeup optimisation introduced by commit a9af97aa0a12
("powerpc/64s: msgclr when handling doorbell exceptions from system
reset").

This patch restores it, in C code. It's moved explicitly to the system
reset wakeup path, rather than the doorbell replay path, because it is
always the right thing to do in the wakeup case, but it could be rare to
have a pending message in other cases in which case it's wasted work --
we would have to be done to see if that was a worthwhile optimisation,
and I suspect it would not be.

The results are similar to those in the original commit, test on POWER8
of context_switch selftests benchmark with polling idle disabled (e.g.,
always nap, giving cross-CPU IPIs) gives the following results:

                                    broken           patched
    Different threads, same core:   317k/s           375k/s    +18.7%
    Different cores:                280k/s           282k/s     +1.0%

Fixes: 3282a3da25bd ("powerpc/64: Implement soft interrupt replay in C")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 19 -------------------
 arch/powerpc/kernel/irq.c            | 13 +++++++++++++
 2 files changed, 13 insertions(+), 19 deletions(-)

Comments

Michael Ellerman April 6, 2020, 1:05 p.m. UTC | #1
On Thu, 2020-04-02 at 12:12:12 UTC, Nicholas Piggin wrote:
> Commit 3282a3da25bd ("powerpc/64: Implement soft interrupt replay in C")
> broke the doorbell wakeup optimisation introduced by commit a9af97aa0a12
> ("powerpc/64s: msgclr when handling doorbell exceptions from system
> reset").
> 
> This patch restores it, in C code. It's moved explicitly to the system
> reset wakeup path, rather than the doorbell replay path, because it is
> always the right thing to do in the wakeup case, but it could be rare to
> have a pending message in other cases in which case it's wasted work --
> we would have to be done to see if that was a worthwhile optimisation,
> and I suspect it would not be.
> 
> The results are similar to those in the original commit, test on POWER8
> of context_switch selftests benchmark with polling idle disabled (e.g.,
> always nap, giving cross-CPU IPIs) gives the following results:
> 
>                                     broken           patched
>     Different threads, same core:   317k/s           375k/s    +18.7%
>     Different cores:                280k/s           282k/s     +1.0%
> 
> Fixes: 3282a3da25bd ("powerpc/64: Implement soft interrupt replay in C")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/0c89649a70bed679fd408c1eb82fa99dbe1354a0

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 18bbce143084..728ccb0f560c 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -3121,22 +3121,3 @@  handle_dabr_fault:
 	li	r5,SIGSEGV
 	bl	bad_page_fault
 	b	interrupt_return
-
-/*
- * When doorbell is triggered from system reset wakeup, the message is
- * not cleared, so it would fire again when EE is enabled.
- *
- * When coming from local_irq_enable, there may be the same problem if
- * we were hard disabled.
- *
- * Execute msgclr to clear pending exceptions before handling it.
- */
-h_doorbell_common_msgclr:
-	LOAD_REG_IMMEDIATE(r3, PPC_DBELL_MSGTYPE << (63-36))
-	PPC_MSGCLR(3)
-	b 	h_doorbell_common_virt
-
-doorbell_super_common_msgclr:
-	LOAD_REG_IMMEDIATE(r3, PPC_DBELL_MSGTYPE << (63-36))
-	PPC_MSGCLRP(3)
-	b 	doorbell_super_common_virt
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 6ea27dbcb872..ed6230ba0c43 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -527,6 +527,19 @@  void irq_set_pending_from_srr1(unsigned long srr1)
 		return;
 	}
 
+	if (reason == PACA_IRQ_DBELL) {
+		/*
+		 * When doorbell triggers a system reset wakeup, the message
+		 * is not cleared, so if the doorbell interrupt is replayed
+		 * and the IPI handled, the doorbell interrupt would still
+		 * fire when EE is enabled.
+		 *
+		 * To avoid taking the superfluous doorbell interrupt,
+		 * execute a msgclr here before the interrupt is replayed.
+		 */
+		ppc_msgclr(PPC_DBELL_MSGTYPE);
+	}
+
 	/*
 	 * The 0 index (SRR1[42:45]=b0000) must always evaluate to 0,
 	 * so this can be called unconditionally with the SRR1 wake