From: Gautam Menghani <gautam@linux.ibm.com>
To: mpe@ellerman.id.au, npiggin@gmail.com,
christophe.leroy@csgroup.eu, naveen.n.rao@linux.ibm.com
Cc: Gautam Menghani <gautam@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org
Subject: [PATCH 1/3] arch/powerpc/kvm: Use bitmap to speed up resend of irqs in ICS
Date: Mon, 6 May 2024 21:47:29 +0530 [thread overview]
Message-ID: <20240506161735.83358-2-gautam@linux.ibm.com> (raw)
In-Reply-To: <20240506161735.83358-1-gautam@linux.ibm.com>
When an irq is to be resent, all 1024 irqs in an ICS are scanned and the
irqs having 'resend' flag set are resent. Optimize this flow using bitmap
array to speed up the resends.
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
arch/powerpc/kvm/book3s_xics.c | 22 +++++++++++-----------
arch/powerpc/kvm/book3s_xics.h | 1 +
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c
index 589a8f257120..12de526f04c4 100644
--- a/arch/powerpc/kvm/book3s_xics.c
+++ b/arch/powerpc/kvm/book3s_xics.c
@@ -47,9 +47,6 @@
* TODO
* ====
*
- * - To speed up resends, keep a bitmap of "resend" set bits in the
- * ICS
- *
* - Speed up server# -> ICP lookup (array ? hash table ?)
*
* - Make ICS lockless as well, or at least a per-interrupt lock or hashed
@@ -125,15 +122,17 @@ static int ics_deliver_irq(struct kvmppc_xics *xics, u32 irq, u32 level)
static void ics_check_resend(struct kvmppc_xics *xics, struct kvmppc_ics *ics,
struct kvmppc_icp *icp)
{
- int i;
+ u32 irq;
+ struct ics_irq_state *state;
- for (i = 0; i < KVMPPC_XICS_IRQ_PER_ICS; i++) {
- struct ics_irq_state *state = &ics->irq_state[i];
- if (state->resend) {
- XICS_DBG("resend %#x prio %#x\n", state->number,
- state->priority);
- icp_deliver_irq(xics, icp, state->number, true);
- }
+ for_each_set_bit(irq, ics->resend_map, KVMPPC_XICS_IRQ_PER_ICS) {
+ state = &ics->irq_state[irq];
+
+ if (!test_and_clear_bit(irq, ics->resend_map))
+ continue;
+ if (!state)
+ continue;
+ icp_deliver_irq(xics, icp, state->number, true);
}
}
@@ -489,6 +488,7 @@ static void icp_deliver_irq(struct kvmppc_xics *xics, struct kvmppc_icp *icp,
*/
smp_wmb();
set_bit(ics->icsid, icp->resend_map);
+ set_bit(src, ics->resend_map);
/*
* If the need_resend flag got cleared in the ICP some time
diff --git a/arch/powerpc/kvm/book3s_xics.h b/arch/powerpc/kvm/book3s_xics.h
index 08fb0843faf5..8fcb34ea47a4 100644
--- a/arch/powerpc/kvm/book3s_xics.h
+++ b/arch/powerpc/kvm/book3s_xics.h
@@ -98,6 +98,7 @@ struct kvmppc_ics {
arch_spinlock_t lock;
u16 icsid;
struct ics_irq_state irq_state[KVMPPC_XICS_IRQ_PER_ICS];
+ DECLARE_BITMAP(resend_map, KVMPPC_XICS_IRQ_PER_ICS);
};
struct kvmppc_xics {
--
2.44.0
next prev parent reply other threads:[~2024-05-06 16:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 16:17 [PATCH 0/3] XICS emulation optimizations in KVM for PPC Gautam Menghani
2024-05-06 16:17 ` Gautam Menghani [this message]
2024-05-06 16:17 ` [PATCH 2/3] arch/powerpc/kvm: Optimize the server number -> ICP lookup Gautam Menghani
2024-05-06 16:17 ` [PATCH 3/3] arch/powerpc/kvm: Reduce lock contention by moving spinlock from ics to irq_state Gautam Menghani
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=20240506161735.83358-2-gautam@linux.ibm.com \
--to=gautam@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.ibm.com \
--cc=npiggin@gmail.com \
/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).