From: Sean Christopherson <seanjc@google.com>
To: Yanfei Xu <isyanfei.xu@gmail.com>
Cc: Yanfei Xu <yanfei.xu@bytedance.com>,
pbonzini@redhat.com, kvm@vger.kernel.org,
caixiangfeng@bytedance.com, fangying.tommy@bytedance.com
Subject: Re: [PATCH v2] KVM: irqchip: KVM: Reduce allocation overhead in kvm_set_irq_routing()
Date: Mon, 18 May 2026 07:57:04 -0700 [thread overview]
Message-ID: <agsowFVyWElj7zMM@google.com> (raw)
In-Reply-To: <ccae4c1b-719c-4bbd-9f2c-251364fa4fb3@gmail.com>
On Mon, May 18, 2026, Yanfei Xu wrote:
> On 2026/5/16 02:52, Sean Christopherson wrote:
> > On Fri, Dec 26, 2025, Yanfei Xu wrote:
> > And if we're going to allocate one massive array, then we definitely should get
> > rid of:
> >
> > /*
> > * Array indexed by gsi. Each entry contains list of irq chips
> > * the gsi is connected to.
> > */
> > struct hlist_head map[];
> >
> > and kvm_kernel_irq_routing_entry.list. It'd be easier and faster to have
> > setup_routing_entry() simply iterate over the array.
>
> if we get rid of these, we need to add a new field to record the offset of
> entries belonging to the same GSI. Compared to the hlist-based lookup, I am
> not sure this would yield a clear gain. Seems hlist feels more
> straightforward?
Gah, right, I was thinking the array was indexed by GSI, but it's indexed by the
arbitrary order provided by userspace. And even ignoring the case where a GSI
has multiple routes, indexing by GSI would massively over-allocate if the routing
table is sparsely populated.
> > Something we should look at (on top of this), is caching the previous routing
> > table. I.e. instead of freeing the old table, keep it around, and try to reuse
> > the old table on the next update. That would allow eliding the alloc+free
> > entirely when userspace is changing routing, but not adding or removing entries.
>
> In our live-upgrade scenario, userspace incrementally adds entries via a
> large number of KVM_SET_GSI_ROUTING ioctls, so the cost is dominated by the
> cumulative overhead across tens of thousands of alloc/free pairs.
Yes, but your live-upgrade scenario isn't the only thing KVM supports :-)
> Per my observation, the per-call alloc/free overhead is fine; it's the
> cumulative cost that hurts.
That might change with vmalloc'd memory, where tearing down the mappings requires
TLB shutdowns. And as above, even if it's not a problem for _your_ scenario, the
overhead might be meaningful for other setups. If we can cheaply/easily provide
meaningful performance benefits for such setups, then why not...
next prev parent reply other threads:[~2026-05-18 14:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-26 6:27 [PATCH v2] KVM: irqchip: KVM: Reduce allocation overhead in kvm_set_irq_routing() Yanfei Xu
2026-01-19 8:53 ` Yanfei Xu
2026-05-15 18:52 ` Sean Christopherson
2026-05-18 12:56 ` Yanfei Xu
2026-05-18 14:57 ` Sean Christopherson [this message]
2026-05-20 6:37 ` Yanfei Xu
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=agsowFVyWElj7zMM@google.com \
--to=seanjc@google.com \
--cc=caixiangfeng@bytedance.com \
--cc=fangying.tommy@bytedance.com \
--cc=isyanfei.xu@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yanfei.xu@bytedance.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.