From: Zenghui Yu <yuzenghui@huawei.com>
To: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <alex.williamson@redhat.com>, <cohuck@redhat.com>,
<wanghaibin.wang@huawei.com>, Zenghui Yu <yuzenghui@huawei.com>
Subject: [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty
Date: Mon, 21 Sep 2020 12:51:16 +0800 [thread overview]
Message-ID: <20200921045116.258-2-yuzenghui@huawei.com> (raw)
In-Reply-To: <20200921045116.258-1-yuzenghui@huawei.com>
Now we regenerate vconfig for all the BARs via vfio_bar_fixup(), every time
any offset of any of them are read. Though BARs aren't re-read regularly,
the regeneration can be avoid if no BARs had been written since they were
last read, in which case the vdev->bardirty is false.
Let's predicate the vfio_bar_fixup() on the bardirty so that it can return
immediately if !bardirty.
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
* From v1:
- Per Alex's suggestion, let vfio_bar_fixup() test vdev->bardirty to
avoid doing work if bardirty is false, instead of removing it entirely.
- Rewrite the commit message.
drivers/vfio/pci/vfio_pci_config.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index d98843feddce..5e02ba07e8e8 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -467,6 +467,9 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev)
__le32 *vbar;
u64 mask;
+ if (!vdev->bardirty)
+ return;
+
vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0];
for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) {
--
2.19.1
next prev parent reply other threads:[~2020-09-21 4:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 4:51 [PATCH v2 1/2] vfio/pci: Remove redundant declaration of vfio_pci_driver Zenghui Yu
2020-09-21 4:51 ` Zenghui Yu [this message]
2020-09-21 10:21 ` [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty Cornelia Huck
2020-09-21 11:28 ` Zenghui Yu
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=20200921045116.258-2-yuzenghui@huawei.com \
--to=yuzenghui@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wanghaibin.wang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox