linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] vfio/pci: Remove redundant declaration of vfio_pci_driver
@ 2020-09-21  4:51 Zenghui Yu
  2020-09-21  4:51 ` [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty Zenghui Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2020-09-21  4:51 UTC (permalink / raw)
  To: kvm, linux-kernel; +Cc: alex.williamson, cohuck, wanghaibin.wang, Zenghui Yu

It was added by commit 137e5531351d ("vfio/pci: Add sriov_configure
support") but duplicates a forward declaration earlier in the file.

Remove it.

Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
* From v1:
  - Clarify the commit message per Alex's suggestion.
  - Add Cornelia's R-b tag.

 drivers/vfio/pci/vfio_pci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 1ab1f5cda4ac..da68e2f86622 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1862,7 +1862,6 @@ static const struct vfio_device_ops vfio_pci_ops = {
 
 static int vfio_pci_reflck_attach(struct vfio_pci_device *vdev);
 static void vfio_pci_reflck_put(struct vfio_pci_reflck *reflck);
-static struct pci_driver vfio_pci_driver;
 
 static int vfio_pci_bus_notifier(struct notifier_block *nb,
 				 unsigned long action, void *data)
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty
  2020-09-21  4:51 [PATCH v2 1/2] vfio/pci: Remove redundant declaration of vfio_pci_driver Zenghui Yu
@ 2020-09-21  4:51 ` Zenghui Yu
  2020-09-21 10:21   ` Cornelia Huck
  0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2020-09-21  4:51 UTC (permalink / raw)
  To: kvm, linux-kernel; +Cc: alex.williamson, cohuck, wanghaibin.wang, Zenghui Yu

Now we regenerate vconfig for all the BARs via vfio_bar_fixup(), every time
any offset of any of them are read. Though BARs aren't re-read regularly,
the regeneration can be avoid if no BARs had been written since they were
last read, in which case the vdev->bardirty is false.

Let's predicate the vfio_bar_fixup() on the bardirty so that it can return
immediately if !bardirty.

Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
* From v1:
  - Per Alex's suggestion, let vfio_bar_fixup() test vdev->bardirty to
    avoid doing work if bardirty is false, instead of removing it entirely.
  - Rewrite the commit message.

 drivers/vfio/pci/vfio_pci_config.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index d98843feddce..5e02ba07e8e8 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -467,6 +467,9 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev)
 	__le32 *vbar;
 	u64 mask;
 
+	if (!vdev->bardirty)
+		return;
+
 	vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0];
 
 	for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) {
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty
  2020-09-21  4:51 ` [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty Zenghui Yu
@ 2020-09-21 10:21   ` Cornelia Huck
  2020-09-21 11:28     ` Zenghui Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Cornelia Huck @ 2020-09-21 10:21 UTC (permalink / raw)
  To: Zenghui Yu; +Cc: kvm, linux-kernel, alex.williamson, wanghaibin.wang

On Mon, 21 Sep 2020 12:51:16 +0800
Zenghui Yu <yuzenghui@huawei.com> wrote:

> Now we regenerate vconfig for all the BARs via vfio_bar_fixup(), every time
> any offset of any of them are read. Though BARs aren't re-read regularly,
> the regeneration can be avoid if no BARs had been written since they were

s/avoid/avoided/

> last read, in which case the vdev->bardirty is false.

s/the//

> 
> Let's predicate the vfio_bar_fixup() on the bardirty so that it can return
> immediately if !bardirty.

Maybe

"Let's return immediately in vfio_bar_fixup() if bardirty is false." ?

> 
> Suggested-by: Alex Williamson <alex.williamson@redhat.com>
> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
> ---
> * From v1:
>   - Per Alex's suggestion, let vfio_bar_fixup() test vdev->bardirty to
>     avoid doing work if bardirty is false, instead of removing it entirely.
>   - Rewrite the commit message.
> 
>  drivers/vfio/pci/vfio_pci_config.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
> index d98843feddce..5e02ba07e8e8 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -467,6 +467,9 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev)
>  	__le32 *vbar;
>  	u64 mask;
> 
> +	if (!vdev->bardirty)

Finally, bardirty can actually affect something :)

> +		return;
> +
>  	vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0];
>  
>  	for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) {

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty
  2020-09-21 10:21   ` Cornelia Huck
@ 2020-09-21 11:28     ` Zenghui Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Zenghui Yu @ 2020-09-21 11:28 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, linux-kernel, alex.williamson, wanghaibin.wang

Hi Cornelia,

On 2020/9/21 18:21, Cornelia Huck wrote:
> On Mon, 21 Sep 2020 12:51:16 +0800
> Zenghui Yu <yuzenghui@huawei.com> wrote:
> 
>> Now we regenerate vconfig for all the BARs via vfio_bar_fixup(), every time
>> any offset of any of them are read. Though BARs aren't re-read regularly,
>> the regeneration can be avoid if no BARs had been written since they were
> 
> s/avoid/avoided/
> 
>> last read, in which case the vdev->bardirty is false.
> 
> s/the//
> 
>>
>> Let's predicate the vfio_bar_fixup() on the bardirty so that it can return
>> immediately if !bardirty.
> 
> Maybe
> 
> "Let's return immediately in vfio_bar_fixup() if bardirty is false." ?

Yes.

>>
>> Suggested-by: Alex Williamson <alex.williamson@redhat.com>
>> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
>> ---
>> * From v1:
>>    - Per Alex's suggestion, let vfio_bar_fixup() test vdev->bardirty to
>>      avoid doing work if bardirty is false, instead of removing it entirely.
>>    - Rewrite the commit message.
>>
>>   drivers/vfio/pci/vfio_pci_config.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
>> index d98843feddce..5e02ba07e8e8 100644
>> --- a/drivers/vfio/pci/vfio_pci_config.c
>> +++ b/drivers/vfio/pci/vfio_pci_config.c
>> @@ -467,6 +467,9 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev)
>>   	__le32 *vbar;
>>   	u64 mask;
>>
>> +	if (!vdev->bardirty)
> 
> Finally, bardirty can actually affect something :)
> 
>> +		return;
>> +
>>   	vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0];
>>   
>>   	for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) {
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Thanks for you review! I think Alex can help fix the commit message when
applying? Otherwise I can send a v3.


Thanks,
Zenghui

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-21 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21  4:51 [PATCH v2 1/2] vfio/pci: Remove redundant declaration of vfio_pci_driver Zenghui Yu
2020-09-21  4:51 ` [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty Zenghui Yu
2020-09-21 10:21   ` Cornelia Huck
2020-09-21 11:28     ` Zenghui Yu

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).