From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Huaitong Han <hanht2@chinatelecom.cn>,
Zhiyuan Yuan <yuanzhiyuan@chinatelecom.cn>,
Jidong Xia <xiajd@chinatelecom.cn>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: [PULL 23/31] vhost: Don't set vring call if guest notifier is unused
Date: Sun, 1 Jun 2025 11:25:41 -0400 [thread overview]
Message-ID: <51ee7357e9e6e017fc25837743bef0a18aeafbe6.1748791463.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1748791463.git.mst@redhat.com>
From: Huaitong Han <hanht2@chinatelecom.cn>
The vring call fd is set even when the guest does not use MSI-X (e.g., in the
case of virtio PMD), leading to unnecessary CPU overhead for processing
interrupts.
The commit 96a3d98d2c("vhost: don't set vring call if no vector") optimized the
case where MSI-X is enabled but the queue vector is unset. However, there's an
additional case where the guest uses INTx and the INTx_DISABLED bit in the PCI
config is set, meaning that no interrupt notifier will actually be used.
In such cases, the vring call fd should also be cleared to avoid redundant
interrupt handling.
Fixes: 96a3d98d2c("vhost: don't set vring call if no vector")
Reported-by: Zhiyuan Yuan <yuanzhiyuan@chinatelecom.cn>
Signed-off-by: Jidong Xia <xiajd@chinatelecom.cn>
Signed-off-by: Huaitong Han <hanht2@chinatelecom.cn>
Message-Id: <20250522100548.212740-1-hanht2@chinatelecom.cn>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/pci/pci.h | 1 +
hw/pci/pci.c | 2 +-
hw/virtio/virtio-pci.c | 7 ++++++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index a6854dad2b..35d59d7672 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -983,6 +983,7 @@ void lsi53c8xx_handle_legacy_cmdline(DeviceState *lsi_dev);
qemu_irq pci_allocate_irq(PCIDevice *pci_dev);
void pci_set_irq(PCIDevice *pci_dev, int level);
+int pci_irq_disabled(PCIDevice *d);
static inline void pci_irq_assert(PCIDevice *pci_dev)
{
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index c6b5768f3a..9b4bf48439 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1730,7 +1730,7 @@ static void pci_update_mappings(PCIDevice *d)
pci_update_vga(d);
}
-static inline int pci_irq_disabled(PCIDevice *d)
+int pci_irq_disabled(PCIDevice *d)
{
return pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_INTX_DISABLE;
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 9b48aa8c3e..7e309d1d49 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1215,7 +1215,12 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
static bool virtio_pci_query_guest_notifiers(DeviceState *d)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
- return msix_enabled(&proxy->pci_dev);
+
+ if (msix_enabled(&proxy->pci_dev)) {
+ return true;
+ } else {
+ return pci_irq_disabled(&proxy->pci_dev);
+ }
}
static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
--
MST
next prev parent reply other threads:[~2025-06-01 15:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-01 15:24 [PULL 00/31] virtio,pci,pc: features, fixes, tests Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 01/31] virtio: check for validity of indirect descriptors Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 02/31] hw/i386/amd_iommu: Fix device setup failure when PT is on Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 03/31] hw/i386/amd_iommu: Fix xtsup when vcpus < 255 Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 04/31] pcie: Add helper to declare PASID capability for a pcie device Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 05/31] pcie: Helper functions to check if PASID is enabled Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 06/31] pcie: Helper function to check if ATS " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 07/31] pcie: Add a helper to declare the PRI capability for a pcie device Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 08/31] pcie: Helper functions to check to check if PRI is enabled Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 09/31] pci: Cache the bus mastering status in the device Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 10/31] pci: Add an API to get IOMMU's min page size and virtual address width Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 11/31] memory: Store user data pointer in the IOMMU notifiers Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 12/31] pci: Add a pci-level initialization function for " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 13/31] pci: Add a pci-level API for ATS Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 14/31] pci: Add a PCI-level API for PRI Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 15/31] uefi-test-tools:: Add LoongArch64 support Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 16/31] tests/data/uefi-boot-images: Add ISO image for LoongArch system Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 17/31] tests/qtest/bios-tables-test: Use MiB macro rather hardcode value Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 18/31] tests/acpi: Add empty ACPI data files for LoongArch Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 19/31] tests/qtest/bios-tables-test: Add basic testing " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 20/31] rebuild-expected-aml.sh: Add support " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 21/31] tests/acpi: Fill acpi table data " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 22/31] tests/acpi: Remove stale allowed tables Michael S. Tsirkin
2025-06-01 15:25 ` Michael S. Tsirkin [this message]
2025-06-01 15:25 ` [PULL 24/31] vdpa: check for iova tree initialized at net_client_start Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 25/31] vdpa: reorder vhost_vdpa_set_backend_cap Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 26/31] vdpa: set backend capabilities at vhost_vdpa_init Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 27/31] vdpa: add listener_registered Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 28/31] vdpa: reorder listener assignment Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 29/31] vdpa: move iova_tree allocation to net_vhost_vdpa_init Michael S. Tsirkin
2025-06-01 15:26 ` [PULL 30/31] vdpa: move memory listener register to vhost_vdpa_init Michael S. Tsirkin
2025-06-01 15:26 ` [PULL 31/31] hw/i386/pc_piix: Fix RTC ISA IRQ wiring of isapc machine Michael S. Tsirkin
2025-06-02 8:39 ` [PULL 00/31] virtio,pci,pc: features, fixes, tests Michael S. Tsirkin
2025-06-02 16:39 ` Stefan Hajnoczi
2025-06-02 17:54 ` Michael S. Tsirkin
2025-06-02 18:25 ` Stefan Hajnoczi
2025-06-02 18:31 ` Michael S. Tsirkin
2025-06-02 21:58 ` Michael S. Tsirkin
2025-06-02 22:27 ` Stefan Hajnoczi
2025-06-03 1:09 ` Bibo Mao
2025-06-02 20:43 ` Stefan Hajnoczi
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=51ee7357e9e6e017fc25837743bef0a18aeafbe6.1748791463.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=hanht2@chinatelecom.cn \
--cc=marcel.apfelbaum@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=xiajd@chinatelecom.cn \
--cc=yuanzhiyuan@chinatelecom.cn \
/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).