[PATCH 3/6] hw/display/virtio-gpu-udmabuf: 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 3/6] hw/display/virtio-gpu-udmabuf: 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/display/virtio-gpu-udmabuf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
index d51184d658..0ee6685803 100644
--- a/hw/display/virtio-gpu-udmabuf.c
+++ b/hw/display/virtio-gpu-udmabuf.c
@@ -42,9 +42,9 @@ static void virtio_gpu_create_udmabuf(struct virtio_gpu_simple_resource *res)
                      sizeof(struct udmabuf_create_item) * res->iov_cnt);
 
     for (i = 0; i < res->iov_cnt; i++) {
-        rcu_read_lock();
-        rb = qemu_ram_block_from_host(res->iov[i].iov_base, false, &offset);
-        rcu_read_unlock();
+        WITH_RCU_READ_LOCK_GUARD() {
+            rb = qemu_ram_block_from_host(res->iov[i].iov_base, false, &offset);
+        }
 
         if (!rb || rb->fd < 0) {
             g_free(list);
-- 
2.41.0


Re: [PATCH 3/6] hw/display/virtio-gpu-udmabuf: Use RCU_READ macro
Posted by Manos Pitsidianakis 10 months, 1 week ago
On Wed, 24 Jan 2024 09:41, 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/display/virtio-gpu-udmabuf.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
>index d51184d658..0ee6685803 100644
>--- a/hw/display/virtio-gpu-udmabuf.c
>+++ b/hw/display/virtio-gpu-udmabuf.c
>@@ -42,9 +42,9 @@ static void virtio_gpu_create_udmabuf(struct virtio_gpu_simple_resource *res)
>                      sizeof(struct udmabuf_create_item) * res->iov_cnt);
> 
>     for (i = 0; i < res->iov_cnt; i++) {
>-        rcu_read_lock();
>-        rb = qemu_ram_block_from_host(res->iov[i].iov_base, false, &offset);
>-        rcu_read_unlock();
>+        WITH_RCU_READ_LOCK_GUARD() {
>+            rb = qemu_ram_block_from_host(res->iov[i].iov_base, false, &offset);
>+        }
> 
>         if (!rb || rb->fd < 0) {
>             g_free(list);
>-- 
>2.41.0

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