From: Zenghui Yu <yuzenghui@huawei.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <wanghaibin.wang@huawei.com>
Subject: Re: [PATCH 2/2] vfio/pci: Remove bardirty from vfio_pci_device
Date: Sat, 19 Sep 2020 10:39:55 +0800 [thread overview]
Message-ID: <254ac8bf-e912-0d01-0295-8bb54f7a88bf@huawei.com> (raw)
In-Reply-To: <20200918201128.16cf0a1c@x1.home>
On 2020/9/19 10:11, Alex Williamson wrote:
> On Sat, 19 Sep 2020 09:54:00 +0800
> Zenghui Yu <yuzenghui@huawei.com> wrote:
>
>> Hi Alex,
>>
>> On 2020/9/18 6:07, Alex Williamson wrote:
>>> On Thu, 17 Sep 2020 13:35:37 +0200
>>> Cornelia Huck <cohuck@redhat.com> wrote:
>>>
>>>> On Thu, 17 Sep 2020 11:31:28 +0800
>>>> Zenghui Yu <yuzenghui@huawei.com> wrote:
>>>>
>>>>> It isn't clear what purpose the @bardirty serves. It might be used to avoid
>>>>> the unnecessary vfio_bar_fixup() invoking on a user-space BAR read, which
>>>>> is not required when bardirty is unset.
>>>>>
>>>>> The variable was introduced in commit 89e1f7d4c66d ("vfio: Add PCI device
>>>>> driver") but never actually used, so it shouldn't be that important. Remove
>>>>> it.
>>>>>
>>>>> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
>>>>> ---
>>>>> drivers/vfio/pci/vfio_pci_config.c | 7 -------
>>>>> drivers/vfio/pci/vfio_pci_private.h | 1 -
>>>>> 2 files changed, 8 deletions(-)
>>>>
>>>> Yes, it seems to have been write-only all the time.
>>>
>>> I suspect the intent was that vfio_bar_fixup() could test
>>> vdev->bardirty to avoid doing work if no BARs had been written since
>>> they were last read. As it is now we regenerate vconfig for all the
>>> BARs every time any offset of any of them are read. BARs aren't
>>> re-read regularly and config space is not a performance path,
>>
>> Yes, it seems that Qemu itself emulates all BAR registers and will read
>> the BAR from the kernel side only at initialization time.
>>
>>> but maybe
>>> we should instead test if we see any regressions from returning without
>>> doing any work in vfio_bar_fixup() if vdev->bardirty is false. Thanks,
>>
>> I will test it with the following diff. Please let me know which way do
>> you prefer.
>>
>> diff --git a/drivers/vfio/pci/vfio_pci_config.c
>> b/drivers/vfio/pci/vfio_pci_config.c
>> index d98843feddce..77c419d536d0 100644
>> --- a/drivers/vfio/pci/vfio_pci_config.c
>> +++ b/drivers/vfio/pci/vfio_pci_config.c
>> @@ -515,7 +515,7 @@ static int vfio_basic_config_read(struct
>> vfio_pci_device *vdev, int pos,
>> int count, struct perm_bits *perm,
>> int offset, __le32 *val)
>> {
>> - if (is_bar(offset)) /* pos == offset for basic config */
>> + if (is_bar(offset) && vdev->bardirty) /* pos == offset for basic
>> config */
>> vfio_bar_fixup(vdev);
>>
>> count = vfio_default_config_read(vdev, pos, count, perm,
>> offset, val);
>
>
> There's only one caller currently, but I'd think it cleaner to put this
> in vfio_bar_fixup(), ie. return immediately if !bardirty. Thanks,
OK, I'll do that in the v2.
Thanks,
Zenghui
next prev parent reply other threads:[~2020-09-19 2:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 3:31 [PATCH 1/2] vfio/pci: Remove redundant declaration of vfio_pci_driver Zenghui Yu
2020-09-17 3:31 ` [PATCH 2/2] vfio/pci: Remove bardirty from vfio_pci_device Zenghui Yu
2020-09-17 11:35 ` Cornelia Huck
2020-09-17 22:07 ` Alex Williamson
2020-09-19 1:54 ` Zenghui Yu
2020-09-19 2:11 ` Alex Williamson
2020-09-19 2:39 ` Zenghui Yu [this message]
2020-09-17 11:26 ` [PATCH 1/2] vfio/pci: Remove redundant declaration of vfio_pci_driver Cornelia Huck
2020-09-17 22:22 ` Alex Williamson
2020-09-19 1:56 ` 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=254ac8bf-e912-0d01-0295-8bb54f7a88bf@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;
as well as URLs for NNTP newsgroup(s).