[PATCH 6/6] hw/virtio/vhost: Use RCU_READ macro

Philippe Mathieu-Daudé posted 6 patches 10 months, 1 week ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Greg Kurz <groug@kaod.org>, Christian Schoenebeck <qemu_oss@crudebyte.com>, Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Fam Zheng <fam@euphon.net>, Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>
[PATCH 6/6] hw/virtio/vhost: Use RCU_READ macro
Posted by Philippe Mathieu-Daudé 10 months, 1 week ago
Replace the manual rcu_read_(un)lock calls by the
WITH_RCU_READ_LOCK_GUARD macro (See commit ef46ae67ba
"docs/style: call out the use of GUARD macros").

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/virtio/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 2c9ac79468..1f5ecb843e 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -186,12 +186,12 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
             hwaddr phys, s, offset;
 
             while (used_size) {
-                rcu_read_lock();
-                iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
+                WITH_RCU_READ_LOCK_GUARD() {
+                    iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
                                                       used_phys,
                                                       true,
                                                       MEMTXATTRS_UNSPECIFIED);
-                rcu_read_unlock();
+                }
 
                 if (!iotlb.target_as) {
                     qemu_log_mask(LOG_GUEST_ERROR, "translation "
-- 
2.41.0


Re: [PATCH 6/6] hw/virtio/vhost: Use RCU_READ macro
Posted by Manos Pitsidianakis 10 months, 1 week ago
On Wed, 24 Jan 2024 09:42, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>Replace the manual rcu_read_(un)lock calls by the
>WITH_RCU_READ_LOCK_GUARD macro (See commit ef46ae67ba
>"docs/style: call out the use of GUARD macros").
>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>---
> hw/virtio/vhost.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>index 2c9ac79468..1f5ecb843e 100644
>--- a/hw/virtio/vhost.c
>+++ b/hw/virtio/vhost.c
>@@ -186,12 +186,12 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
>             hwaddr phys, s, offset;
> 
>             while (used_size) {
>-                rcu_read_lock();
>-                iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
>+                WITH_RCU_READ_LOCK_GUARD() {
>+                    iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
>                                                       used_phys,
>                                                       true,
>                                                       MEMTXATTRS_UNSPECIFIED);
>-                rcu_read_unlock();
>+                }
> 
>                 if (!iotlb.target_as) {
>                     qemu_log_mask(LOG_GUEST_ERROR, "translation "
>-- 
>2.41.0
>

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>