From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 517CFCA9EC5 for ; Wed, 30 Oct 2019 10:56:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E3FA20717 for ; Wed, 30 Oct 2019 10:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbfJ3K4t (ORCPT ); Wed, 30 Oct 2019 06:56:49 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:59254 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726761AbfJ3K4s (ORCPT ); Wed, 30 Oct 2019 06:56:48 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id AD30DCE6CB8B683BAC3B; Wed, 30 Oct 2019 18:56:45 +0800 (CST) Received: from huawei.com (10.175.105.18) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Wed, 30 Oct 2019 18:56:39 +0800 From: linmiaohe To: , , , , , , , CC: , , Subject: [PATCH] VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find Date: Wed, 30 Oct 2019 18:57:10 +0800 Message-ID: <1572433030-6267-1-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.105.18] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaohe Lin 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 --- 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