kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] irqbypass: Cleanups and a perf improvement
@ 2025-04-04 21:14 Sean Christopherson
  2025-04-04 21:14 ` [PATCH 1/7] irqbypass: Drop pointless and misleading THIS_MODULE get/put Sean Christopherson
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Sean Christopherson @ 2025-04-04 21:14 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Alex Williamson
  Cc: kvm, virtualization, netdev, linux-kernel, Sean Christopherson,
	Oliver Upton, David Matlack, Like Xu, Yong He

The two primary goals of this series are to make the irqbypass concept
easier to understand, and to address the terrible performance that can
result from using a list to track connections.

For the first goal, track the producer/consumer "tokens" as eventfd context
pointers instead of opaque "void *".  Supporting arbitrary token types was
dead infrastructure when it was added 10 years ago, and nothing has changed
since.  Taking an opaque token makes a *very* simple concept (device signals
eventfd; KVM listens to eventfd) unnecessarily difficult to understand.

Burying that simple behind a layer of obfuscation also makes the overall
code more brittle, as callers can pass in literally anything. I.e. passing
in a token that will never be paired would go unnoticed.

For the performance issue, use an xarray.  I'm definitely not wedded to an
xarray, but IMO it doesn't add meaningful complexity (even requires less
code), and pretty much Just Works.  Like tried this a while back[1], but
the implementation had undesirable behavior changes and stalled out.

To address the use case where huge numbers of VMs are being created without
_any_ possibility for irqbypass, KVM should probably add a
KVM_IRQFD_FLAG_NO_IRQBYPASS flag so that userspace can opt-out on a per-IRQ
basis.  I already proposed a KVM module param[2] to let userspace disable
IRQ bypass, but that obviously affects all IRQs in all VMs.  It might
suffice for most use cases, but I can imagine scenarios where the VMM wants
to be more selective, e.g. when it *knows* a KVM_IRQFD isn't eligible for
bypass.  And both of those require userspace changes.

Note, I want to do more aggressive cleanups of irqbypass at some point,
e.g. not reporting an error to userspace if connect() fails is *awful*
behavior for environments that want/need irqbypass to always work.  But
that's a future problem.

[1] https://lore.kernel.org/all/20230801115646.33990-1-likexu@tencent.com
[2] https://lore.kernel.org/all/20250401161804.842968-1-seanjc@google.com

Sean Christopherson (7):
  irqbypass: Drop pointless and misleading THIS_MODULE get/put
  irqbypass: Drop superfluous might_sleep() annotations
  irqbypass: Take ownership of producer/consumer token tracking
  irqbypass: Explicitly track producer and consumer bindings
  irqbypass: Use paired consumer/producer to disconnect during
    unregister
  irqbypass: Use guard(mutex) in lieu of manual lock+unlock
  irqbypass: Use xarray to track producers and consumers

 drivers/vfio/pci/vfio_pci_intrs.c |   5 +-
 drivers/vhost/vdpa.c              |   4 +-
 include/linux/irqbypass.h         |  38 +++---
 virt/kvm/eventfd.c                |   3 +-
 virt/lib/irqbypass.c              | 185 ++++++++++--------------------
 5 files changed, 88 insertions(+), 147 deletions(-)


base-commit: 782f9feaa9517caf33186dcdd6b50a8f770ed29b
-- 
2.49.0.504.g3bcea36a83-goog


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-04-11  0:09 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 21:14 [PATCH 0/7] irqbypass: Cleanups and a perf improvement Sean Christopherson
2025-04-04 21:14 ` [PATCH 1/7] irqbypass: Drop pointless and misleading THIS_MODULE get/put Sean Christopherson
2025-04-10  7:12   ` Tian, Kevin
2025-04-04 21:14 ` [PATCH 2/7] irqbypass: Drop superfluous might_sleep() annotations Sean Christopherson
2025-04-10  7:13   ` Tian, Kevin
2025-04-04 21:14 ` [PATCH 3/7] irqbypass: Take ownership of producer/consumer token tracking Sean Christopherson
2025-04-10  7:28   ` Tian, Kevin
2025-04-10 15:51     ` Sean Christopherson
2025-04-10 21:28   ` Alex Williamson
2025-04-10 22:04     ` Sean Christopherson
2025-04-10 22:25       ` Alex Williamson
2025-04-04 21:14 ` [PATCH 4/7] irqbypass: Explicitly track producer and consumer bindings Sean Christopherson
2025-04-10  7:32   ` Tian, Kevin
2025-04-04 21:14 ` [PATCH 5/7] irqbypass: Use paired consumer/producer to disconnect during unregister Sean Christopherson
2025-04-10  7:34   ` Tian, Kevin
2025-04-04 21:14 ` [PATCH 6/7] irqbypass: Use guard(mutex) in lieu of manual lock+unlock Sean Christopherson
2025-04-10  7:34   ` Tian, Kevin
2025-04-04 21:14 ` [PATCH 7/7] irqbypass: Use xarray to track producers and consumers Sean Christopherson
2025-04-07  3:37   ` Binbin Wu
2025-04-10  7:38   ` Tian, Kevin
2025-04-10 14:52     ` Sean Christopherson
2025-04-11  0:09       ` Tian, Kevin
2025-04-08 11:49 ` [PATCH 0/7] irqbypass: Cleanups and a perf improvement Michael S. Tsirkin

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).