From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Anton Blanchard <anton@linux.ibm.com>,
kvm-ppc@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH] powerpc/pseries: Use doorbells even if XIVE is available
Date: Wed, 24 Jun 2020 23:47:24 +1000 [thread overview]
Message-ID: <20200624134724.2343007-1-npiggin@gmail.com> (raw)
KVM supports msgsndp in guests by trapping and emulating the
instruction, so it was decided to always use XIVE for IPIs if it is
available. However on PowerVM systems, msgsndp can be used and gives
better performance. On large systems, high XIVE interrupt rates can
have sub-linear scaling, and using msgsndp can reduce the load on
the interrupt controller.
So switch to using core local doorbells even if XIVE is available.
This reduces performance for KVM guests with an SMT topology by
about 50% for ping-pong context switching between SMT vCPUs. An
option vector (or dt-cpu-ftrs) could be defined to disable msgsndp
to get KVM performance back.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/pseries/smp.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 6891710833be..a737a2f87c67 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -188,13 +188,14 @@ static int pseries_smp_prepare_cpu(int cpu)
return 0;
}
+static void (*cause_ipi_offcore)(int cpu) __ro_after_init;
+
static void smp_pseries_cause_ipi(int cpu)
{
- /* POWER9 should not use this handler */
if (doorbell_try_core_ipi(cpu))
return;
- icp_ops->cause_ipi(cpu);
+ cause_ipi_offcore(cpu);
}
static int pseries_cause_nmi_ipi(int cpu)
@@ -222,10 +223,7 @@ static __init void pSeries_smp_probe_xics(void)
{
xics_smp_probe();
- if (cpu_has_feature(CPU_FTR_DBELL) && !is_secure_guest())
- smp_ops->cause_ipi = smp_pseries_cause_ipi;
- else
- smp_ops->cause_ipi = icp_ops->cause_ipi;
+ smp_ops->cause_ipi = icp_ops->cause_ipi;
}
static __init void pSeries_smp_probe(void)
@@ -238,6 +236,18 @@ static __init void pSeries_smp_probe(void)
xive_smp_probe();
else
pSeries_smp_probe_xics();
+
+ /*
+ * KVM emulates doorbells by reading the instruction, which
+ * can't be done if the guest is secure. If a secure guest
+ * runs under PowerVM, it could use msgsndp but would need a
+ * way to distinguish.
+ */
+ if (cpu_has_feature(CPU_FTR_DBELL) &&
+ cpu_has_feature(CPU_FTR_SMT) && !is_secure_guest()) {
+ cause_ipi_offcore = smp_ops->cause_ipi;
+ smp_ops->cause_ipi = smp_pseries_cause_ipi;
+ }
}
static struct smp_ops_t pseries_smp_ops = {
--
2.23.0
next reply other threads:[~2020-06-24 13:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 13:47 Nicholas Piggin [this message]
2020-06-25 1:11 ` [PATCH] powerpc/pseries: Use doorbells even if XIVE is available Michael Ellerman
2020-06-26 7:17 ` Cédric Le Goater
2020-06-26 7:26 ` Cédric Le Goater
2020-06-26 7:55 ` Cédric Le Goater
2020-06-27 14:59 ` Nicholas Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200624134724.2343007-1-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=anton@linux.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).