From: linmiaohe <linmiaohe@huawei.com>
To: <alex.williamson@redhat.com>, <cohuck@redhat.com>,
<eric.auger@redhat.com>, <aik@ozlabs.ru>, <mpe@ellerman.id.au>,
<bhelgaas@google.com>, <tglx@linutronix.de>, <hexin.op@gmail.com>
Cc: <linmiaohe@huawei.com>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find
Date: Wed, 30 Oct 2019 18:57:10 +0800 [thread overview]
Message-ID: <1572433030-6267-1-git-send-email-linmiaohe@huawei.com> (raw)
From: Miaohe Lin <linmiaohe@huawei.com>
The driver of the pci device may not equal to vfio_pci_driver,
but we fetch vfio_device from pci_dev unconditionally in func
vfio_pci_reflck_find. This overhead, such as the competition
of vfio.group_lock, can be eliminated by check pci_dev_driver
with vfio_pci_driver first.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
drivers/vfio/pci/vfio_pci.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 379a02c36e37..1e21970543a6 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1466,15 +1466,14 @@ static int vfio_pci_reflck_find(struct pci_dev *pdev, void *data)
struct vfio_device *device;
struct vfio_pci_device *vdev;
- device = vfio_device_get_from_dev(&pdev->dev);
- if (!device)
- return 0;
-
if (pci_dev_driver(pdev) != &vfio_pci_driver) {
- vfio_device_put(device);
return 0;
}
+ device = vfio_device_get_from_dev(&pdev->dev);
+ if (!device)
+ return 0;
+
vdev = vfio_device_data(device);
if (vdev->reflck) {
--
2.19.1
next reply other threads:[~2019-10-30 10:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-30 10:57 linmiaohe [this message]
2019-11-05 19:24 ` [PATCH] VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find Alex Williamson
-- strict thread matches above, loose matches on Subject: below --
2019-11-06 2:02 linmiaohe
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=1572433030-6267-1-git-send-email-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=hexin.op@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpe@ellerman.id.au \
--cc=tglx@linutronix.de \
/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