[PATCH v2] 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/20251007205614.188365-1-mjrosato@linux.ibm.com
Maintainers: Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
hw/s390x/s390-pci-bus.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2] 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.

Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
v2:
 - add review tag
 - tweak commit message (David)
---
 hw/s390x/s390-pci-bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index e8e41c8a9a..88852acf45 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);
+    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
 }
 
 static void s390_pcihost_unrealize(DeviceState *dev)
-- 
2.51.0
Re: [PATCH v2] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Thomas Huth 1 month, 1 week ago
On 07/10/2025 22.56, 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.
> 
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
> v2:
>   - add review tag
>   - tweak commit message (David)
> ---
>   hw/s390x/s390-pci-bus.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index e8e41c8a9a..88852acf45 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);
> +    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
>   }

  Hi Matthew,

this unfortunately fails to compile without KVM (e.g. on x86 hosts):

../../devel/qemu/hw/s390x/s390-pci-bus.c: In function ‘s390_pcihost_realize’:
../../devel/qemu/hw/s390x/s390-pci-bus.c:903:5: error: 
‘kvm_msi_via_irqfd_allowed’ undeclared (first use in this function); did you 
mean ‘kvm_msi_via_irqfd_enabled’?
   903 |     kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
       |     ^~~~~~~~~~~~~~~~~~~~~~~~~
       |     kvm_msi_via_irqfd_enabled
../../devel/qemu/hw/s390x/s390-pci-bus.c:903:5: note: each undeclared 
identifier is reported only once for each function it appears in

  Thomas


Re: [PATCH v2] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Matthew Rosato 1 month, 1 week ago
On 10/8/25 8:51 AM, Thomas Huth wrote:
> On 07/10/2025 22.56, 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.
>>
>> Reviewed-by: Eric Farman <farman@linux.ibm.com>
>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
>> ---
>> v2:
>>   - add review tag
>>   - tweak commit message (David)
>> ---
>>   hw/s390x/s390-pci-bus.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
>> index e8e41c8a9a..88852acf45 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);
>> +    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
>>   }
> 
>  Hi Matthew,
> 
> this unfortunately fails to compile without KVM (e.g. on x86 hosts):
> 
> ../../devel/qemu/hw/s390x/s390-pci-bus.c: In function ‘s390_pcihost_realize’:
> ../../devel/qemu/hw/s390x/s390-pci-bus.c:903:5: error: ‘kvm_msi_via_irqfd_allowed’ undeclared (first use in this function); did you mean ‘kvm_msi_via_irqfd_enabled’?
>   903 |     kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
>       |     ^~~~~~~~~~~~~~~~~~~~~~~~~
>       |     kvm_msi_via_irqfd_enabled
> ../../devel/qemu/hw/s390x/s390-pci-bus.c:903:5: note: each undeclared identifier is reported only once for each function it appears in
>

Argh, thanks for pointing this out.  Of course this value only exists when CONFIG_KVM...

What do you think about using a routine in hw/s390x/s390-pci-kvm.c to set the value (and is a NOP stub when !CONFIG_KVM)?

Thanks,
Matt

Re: [PATCH v2] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Thomas Huth 1 month, 1 week ago
On 08/10/2025 15.19, Matthew Rosato wrote:
> On 10/8/25 8:51 AM, Thomas Huth wrote:
>> On 07/10/2025 22.56, 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.
>>>
>>> Reviewed-by: Eric Farman <farman@linux.ibm.com>
>>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
>>> ---
>>> v2:
>>>    - add review tag
>>>    - tweak commit message (David)
>>> ---
>>>    hw/s390x/s390-pci-bus.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
>>> index e8e41c8a9a..88852acf45 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);
>>> +    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
>>>    }
>>
>>   Hi Matthew,
>>
>> this unfortunately fails to compile without KVM (e.g. on x86 hosts):
>>
>> ../../devel/qemu/hw/s390x/s390-pci-bus.c: In function ‘s390_pcihost_realize’:
>> ../../devel/qemu/hw/s390x/s390-pci-bus.c:903:5: error: ‘kvm_msi_via_irqfd_allowed’ undeclared (first use in this function); did you mean ‘kvm_msi_via_irqfd_enabled’?
>>    903 |     kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
>>        |     ^~~~~~~~~~~~~~~~~~~~~~~~~
>>        |     kvm_msi_via_irqfd_enabled
>> ../../devel/qemu/hw/s390x/s390-pci-bus.c:903:5: note: each undeclared identifier is reported only once for each function it appears in
>>
> 
> Argh, thanks for pointing this out.  Of course this value only exists when CONFIG_KVM...
> 
> What do you think about using a routine in hw/s390x/s390-pci-kvm.c to set the value (and is a NOP stub when !CONFIG_KVM)?

Yes, since we're doing this for some other KVM-related functions there 
already, that sounds like the right way to go here.

  Thomas


Re: [PATCH v2] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Halil Pasic 1 month, 1 week ago
On Tue,  7 Oct 2025 16:56:14 -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.
> 
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Re: [PATCH v2] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by David Hildenbrand 1 month, 1 week ago
On 07.10.25 22:56, 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.
> 
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb
Re: [PATCH v2] s390x/pci: set kvm_msi_via_irqfd_allowed
Posted by Farhan Ali 1 month, 1 week ago
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>

On 10/7/2025 1:56 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.
>
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
> v2:
>   - add review tag
>   - tweak commit message (David)
> ---
>   hw/s390x/s390-pci-bus.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index e8e41c8a9a..88852acf45 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);
> +    kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
>   }
>   
>   static void s390_pcihost_unrealize(DeviceState *dev)