[PATCH v3] s390x/pci: set kvm_msi_via_irqfd_allowed

Matthew Rosato posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251008203350.354121-1-mjrosato@linux.ibm.com
Maintainers: Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>
hw/s390x/s390-pci-bus.c         | 1 +
include/hw/s390x/s390-pci-kvm.h | 7 +++++++
2 files changed, 8 insertions(+)
[PATCH v3] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Matthew Rosato 1 month, 1 week ago
Allow irqfd to be used for virtio-pci on s390x if the kernel supports
it.  This improves s390x virtio-pci performance when using kvm
acceleration by allowing kvm to deliver interrupts instead of QEMU.

Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
v3:
 - Fix builds when !KVM (Thomas). Tested build on x86 and s390.
 - Note: Dropped all review tags due to the code re-organization.
---
 hw/s390x/s390-pci-bus.c         | 1 +
 include/hw/s390x/s390-pci-kvm.h | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index e8e41c8a9a..52820894fa 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -900,6 +900,7 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
     s390_pci_init_default_group();
     css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false,
                              S390_ADAPTER_SUPPRESSIBLE, errp);
+    s390_pcihost_kvm_realize();
 }
 
 static void s390_pcihost_unrealize(DeviceState *dev)
diff --git a/include/hw/s390x/s390-pci-kvm.h b/include/hw/s390x/s390-pci-kvm.h
index 933814a402..c33f2833a3 100644
--- a/include/hw/s390x/s390-pci-kvm.h
+++ b/include/hw/s390x/s390-pci-kvm.h
@@ -14,12 +14,19 @@
 
 #include "hw/s390x/s390-pci-bus.h"
 #include "hw/s390x/s390-pci-inst.h"
+#include "system/kvm.h"
 
 #ifdef CONFIG_KVM
+static inline void s390_pcihost_kvm_realize(void)
+{
+    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
+}
+
 bool s390_pci_kvm_interp_allowed(void);
 int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist);
 int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev);
 #else
+static inline void s390_pcihost_kvm_realize(void) {}
 static inline bool s390_pci_kvm_interp_allowed(void)
 {
     return false;
-- 
2.51.0
Re: [PATCH v3] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Halil Pasic 1 month ago
On Wed,  8 Oct 2025 16:33:50 -0400
Matthew Rosato <mjrosato@linux.ibm.com> wrote:

> Allow irqfd to be used for virtio-pci on s390x if the kernel supports
> it.  This improves s390x virtio-pci performance when using kvm
> acceleration by allowing kvm to deliver interrupts instead of QEMU.
> 
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Re: [PATCH v3] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Farhan Ali 1 month ago
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>

On 10/8/2025 1:33 PM, Matthew Rosato wrote:
> Allow irqfd to be used for virtio-pci on s390x if the kernel supports
> it.  This improves s390x virtio-pci performance when using kvm
> acceleration by allowing kvm to deliver interrupts instead of QEMU.
>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
> v3:
>   - Fix builds when !KVM (Thomas). Tested build on x86 and s390.
>   - Note: Dropped all review tags due to the code re-organization.
> ---
>   hw/s390x/s390-pci-bus.c         | 1 +
>   include/hw/s390x/s390-pci-kvm.h | 7 +++++++
>   2 files changed, 8 insertions(+)
>
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index e8e41c8a9a..52820894fa 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -900,6 +900,7 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp)
>       s390_pci_init_default_group();
>       css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false,
>                                S390_ADAPTER_SUPPRESSIBLE, errp);
> +    s390_pcihost_kvm_realize();
>   }
>   
>   static void s390_pcihost_unrealize(DeviceState *dev)
> diff --git a/include/hw/s390x/s390-pci-kvm.h b/include/hw/s390x/s390-pci-kvm.h
> index 933814a402..c33f2833a3 100644
> --- a/include/hw/s390x/s390-pci-kvm.h
> +++ b/include/hw/s390x/s390-pci-kvm.h
> @@ -14,12 +14,19 @@
>   
>   #include "hw/s390x/s390-pci-bus.h"
>   #include "hw/s390x/s390-pci-inst.h"
> +#include "system/kvm.h"
>   
>   #ifdef CONFIG_KVM
> +static inline void s390_pcihost_kvm_realize(void)
> +{
> +    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
> +}
> +
>   bool s390_pci_kvm_interp_allowed(void);
>   int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist);
>   int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev);
>   #else
> +static inline void s390_pcihost_kvm_realize(void) {}
>   static inline bool s390_pci_kvm_interp_allowed(void)
>   {
>       return false;
Re: [PATCH v3] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Eric Farman 1 month ago
On Wed, 2025-10-08 at 16:33 -0400, Matthew Rosato wrote:
> Allow irqfd to be used for virtio-pci on s390x if the kernel supports
> it.  This improves s390x virtio-pci performance when using kvm
> acceleration by allowing kvm to deliver interrupts instead of QEMU.
> 
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
> v3:
>  - Fix builds when !KVM (Thomas). Tested build on x86 and s390.
>  - Note: Dropped all review tags due to the code re-organization.

Ah, my apologies for missing the !KVM case before.

Reviewed-by: Eric Farman <farman@linux.ibm.com>