vhost-vdpa: make notifiers _init()/_uninit() symmetric
RFC 1/1 vhost-vdpa: make notifiers _init()/_uninit() symmetric
vhost_vdpa_host_notifiers_init() initializes queue notifiers for queues "dev->vq_index" to queue "dev->vq_index + dev->nvqs", whereas vhost_vdpa_host_notifiers_uninit() uninitializes the same notifiers for queue "0" to queue "dev->nvqs".
This asymmetry seems buggy, fix that by using dev->vq_index as the base for both.
--- hw/virtio/vhost-vdpa.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
hw/virtio/vhost-vdpa.c +10 -10
@@ -395,15 +395,6 @@ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, } } -static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) -{ -int i; - -for (i =0 ; i < n; i++) { -vhost_vdpa_host_notifier_uninit (dev, i); - } -} -static int vhost_vdpa_host_notifier_init (struct vhost_dev *dev,int queue_index) {size_t page_size = qemu_real_host_page_size;
@@ -442,6 +433,15 @@ err:return -1 ; } +static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) +{ +int i; + +for (i = dev->vq_index; i < dev->vq_index + n; i++) { +vhost_vdpa_host_notifier_uninit (dev, i); + } +} +static void vhost_vdpa_host_notifiers_init (struct vhost_dev *dev) {int i;
@@ -455,7 +455,7 @@ static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev)return ; err: -vhost_vdpa_host_notifiers_uninit (dev, i); +vhost_vdpa_host_notifiers_uninit (dev, i - dev->vq_index);return ; }
Signature · 1 line
2.34.1
Quoted 38 lines · Laurent Vivier
vhost_vdpa_host_notifiers_init()initializes queue notifiers for queues "dev->vq_index" to queue "dev->vq_index+dev->nvqs", whereasvhost_vdpa_host_notifiers_uninit()uninitializes the same notifiers for queue "0" to queue "dev->nvqs".This asymmetry seems buggy, fix that by using
dev->vq_indexas the base for both.Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")Signed-off-by Laurent Vivier <[email protected]>--- hw/virtio/vhost-vdpa.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)hw/virtio/vhost-vdpa.c +0
-9@@ -395,15 +395,6 @@ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, } } -static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) -{ -int i; - -for (i =0 ; i < n; i++) { -vhost_vdpa_host_notifier_uninit (dev, i); - } -} -static int vhost_vdpa_host_notifier_init (struct vhost_dev *dev,int queue_index) {size_t page_size = qemu_real_host_page_size;@@ -442,6 +433,15 @@ err:return -1 ;
hw/virtio/vhost-vdpa.c err: · line 443
Quoted 10 lines
hw/virtio/vhost-vdpa.c +8
-0} +static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) +{ +int i; + +for (i = dev->vq_index; i < dev->vq_index + n; i++) { +vhost_vdpa_host_notifier_uninit (dev, i); + } +}
Patch looks good but I wonder why we need to move this function?
Thanks
Quoted 16 lines
hw/virtio/vhost-vdpa.c +2
-2+static void vhost_vdpa_host_notifiers_init (struct vhost_dev *dev) {int i;@@ -455,7 +455,7 @@ static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev)return ; err: -vhost_vdpa_host_notifiers_uninit (dev, i); +vhost_vdpa_host_notifiers_uninit (dev, i - dev->vq_index);return ; } --2.34.1
Quoted 41 lines · Jason Wang
Quoted 40 lines · Laurent Vivier
vhost_vdpa_host_notifiers_init()initializes queue notifiers for queues "dev->vq_index" to queue "dev->vq_index+dev->nvqs", whereasvhost_vdpa_host_notifiers_uninit()uninitializes the same notifiers for queue "0" to queue "dev->nvqs".This asymmetry seems buggy, fix that by using
dev->vq_indexas the base for both.Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")Signed-off-by Laurent Vivier <[email protected]>--- hw/virtio/vhost-vdpa.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)hw/virtio/vhost-vdpa.c +0
-9@@ -395,15 +395,6 @@ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, } } -static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) -{ -int i; - -for (i =0 ; i < n; i++) { -vhost_vdpa_host_notifier_uninit (dev, i); - } -} -static int vhost_vdpa_host_notifier_init (struct vhost_dev *dev,int queue_index) {size_t page_size = qemu_real_host_page_size;@@ -442,6 +433,15 @@ err:return -1 ; }
Quoted 10 lines
hw/virtio/vhost-vdpa.c err: · line 443
Quoted 8 lines
hw/virtio/vhost-vdpa.c +8
-0+static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) +{ +int i; + +for (i = dev->vq_index; i < dev->vq_index + n; i++) { +vhost_vdpa_host_notifier_uninit (dev, i); + } +}Patch looks good but I wonder why we need to move this function?
I moved the _uninit function close to the _init one to be able to compare them easier. I think it will help reviewers in the future if code is side-by-side.
But we can let it at its original place.
Thanks,
Laurent
Jason Wang
Acked-byQuoted 54 lines · Laurent Vivier
Quoted 41 lines · Jason Wang
Quoted 40 lines · Laurent Vivier
vhost_vdpa_host_notifiers_init()initializes queue notifiers for queues "dev->vq_index" to queue "dev->vq_index+dev->nvqs", whereasvhost_vdpa_host_notifiers_uninit()uninitializes the same notifiers for queue "0" to queue "dev->nvqs".This asymmetry seems buggy, fix that by using
dev->vq_indexas the base for both.Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")Signed-off-by Laurent Vivier <[email protected]>--- hw/virtio/vhost-vdpa.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)hw/virtio/vhost-vdpa.c +0
-9@@ -395,15 +395,6 @@ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, } } -static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) -{ -int i; - -for (i =0 ; i < n; i++) { -vhost_vdpa_host_notifier_uninit (dev, i); - } -} -static int vhost_vdpa_host_notifier_init (struct vhost_dev *dev,int queue_index) {size_t page_size = qemu_real_host_page_size;@@ -442,6 +433,15 @@ err:return -1 ; }Quoted 10 lines
hw/virtio/vhost-vdpa.c err: · line 443
Quoted 8 lines
hw/virtio/vhost-vdpa.c +8
-0+static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) +{ +int i; + +for (i = dev->vq_index; i < dev->vq_index + n; i++) { +vhost_vdpa_host_notifier_uninit (dev, i); + } +}Patch looks good but I wonder why we need to move this function?
Quoted 2 lines
I moved the
_uninitfunction close to the_initone to be able to compare them easier. I think it will help reviewers in the future if code is side-by-side.
Fine.
So
Thanks
Quoted 6 lines
But we can let it at its original place.
Thanks,
Laurent
Quoted 8 lines · Laurent Vivier
vhost_vdpa_host_notifiers_init()initializes queue notifiers for queues "dev->vq_index" to queue "dev->vq_index+dev->nvqs", whereasvhost_vdpa_host_notifiers_uninit()uninitializes the same notifiers for queue "0" to queue "dev->nvqs".This asymmetry seems buggy, fix that by using
dev->vq_indexas the base for both.
Quoted 6 lines
Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")Signed-off-by Laurent Vivier <[email protected]>---
hw/virtio/vhost-vdpa.c| 20 ++++++++++----------1 file changed, 10 insertions(+), 10 deletions(-)
Quoted 50 lines
hw/virtio/vhost-vdpa.c +9
-9@@ -395,15 +395,6 @@ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, } } -static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) -{ -int i; - -for (i =0 ; i < n; i++) { -vhost_vdpa_host_notifier_uninit (dev, i); - } -} -static int vhost_vdpa_host_notifier_init (struct vhost_dev *dev,int queue_index) {size_t page_size = qemu_real_host_page_size;@@ -442,6 +433,15 @@ err:return -1 ; } +static void vhost_vdpa_host_notifiers_uninit (struct vhost_dev *dev,int n) +{ +int i; + +for (i = dev->vq_index; i < dev->vq_index + n; i++) { +vhost_vdpa_host_notifier_uninit (dev, i); + } +} +static void vhost_vdpa_host_notifiers_init (struct vhost_dev *dev) {int i;@@ -455,7 +455,7 @@ static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev)return ;err:
hw/virtio/vhost-vdpa.c +1
-1-vhost_vdpa_host_notifiers_uninit (dev, i); +vhost_vdpa_host_notifiers_uninit (dev, i - dev->vq_index);return ;}
Signature · 1 line
2.34.1