lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1572433030-6267-1-git-send-email-linmiaohe@huawei.com>
Date:   Wed, 30 Oct 2019 18:57:10 +0800
From:   linmiaohe <linmiaohe@...wei.com>
To:     <alex.williamson@...hat.com>, <cohuck@...hat.com>,
        <eric.auger@...hat.com>, <aik@...abs.ru>, <mpe@...erman.id.au>,
        <bhelgaas@...gle.com>, <tglx@...utronix.de>, <hexin.op@...il.com>
CC:     <linmiaohe@...wei.com>, <kvm@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH] VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find

From: Miaohe Lin <linmiaohe@...wei.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@...wei.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ