From: linmiaohe <linmiaohe@huawei.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: "cohuck@redhat.com" <cohuck@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"aik@ozlabs.ru" <aik@ozlabs.ru>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"hexin.op@gmail.com" <hexin.op@gmail.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find
Date: Wed, 6 Nov 2019 02:02:59 +0000 [thread overview]
Message-ID: <1f2dd537556548ed8e1de9df9eb130c5@huawei.com> (raw)
On Wed, 6 Nov 2019 03:25
Alex Williamson wrote
>> 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.
>>
>
>I believe this introduces a race. When we hold a reference to the vfio device, an unbind from a vfio bus driver will be blocked in vfio_del_group_dev(). Therefore if we test the driver is vfio-pci while holding this reference, we know that it cannot be released and the device_data is a valid vfio_pci_device. Testing the driver prior to acquiring a vfio device reference is meaningless as we have no guarantee that the driver has not changed by the time we acquire a reference. Are you actually seeing contention here or was this a code inspection optimization? Thanks,
>
>Alex
Thanks for your reply and patient explanation. It was a code inspection optimization, and obviously, I missed something. I'm really sorry about that.
Best wishes.
Have a nice day.
next reply other threads:[~2019-11-06 2:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 2:02 linmiaohe [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-10-30 10:57 [PATCH] VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find linmiaohe
2019-11-05 19:24 ` Alex Williamson
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=1f2dd537556548ed8e1de9df9eb130c5@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;
as well as URLs for NNTP newsgroup(s).