[PATCH 2/6] hw/9pfs/9p-synth: 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 2/6] hw/9pfs/9p-synth: 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/9pfs/9p-synth.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index 0ac79a500b..419ea69e3a 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -241,15 +241,15 @@ static struct dirent *synth_get_dentry(V9fsSynthNode *dir,
     int i = 0;
     V9fsSynthNode *node;
 
-    rcu_read_lock();
-    QLIST_FOREACH(node, &dir->child, sibling) {
-        /* This is the off child of the directory */
-        if (i == off) {
-            break;
+    WITH_RCU_READ_LOCK_GUARD() {
+        QLIST_FOREACH(node, &dir->child, sibling) {
+            /* This is the off child of the directory */
+            if (i == off) {
+                break;
+            }
+            i++;
         }
-        i++;
     }
-    rcu_read_unlock();
     if (!node) {
         /* end of directory */
         return NULL;
@@ -494,13 +494,13 @@ static int synth_name_to_path(FsContext *ctx, V9fsPath *dir_path,
         goto out;
     }
     /* search for the name in the children */
-    rcu_read_lock();
-    QLIST_FOREACH(node, &dir_node->child, sibling) {
-        if (!strcmp(node->name, name)) {
-            break;
+    WITH_RCU_READ_LOCK_GUARD() {
+        QLIST_FOREACH(node, &dir_node->child, sibling) {
+            if (!strcmp(node->name, name)) {
+                break;
+            }
         }
     }
-    rcu_read_unlock();
 
     if (!node) {
         errno = ENOENT;
-- 
2.41.0


Re: [PATCH 2/6] hw/9pfs/9p-synth: Use RCU_READ macro
Posted by Christian Schoenebeck 10 months, 1 week ago
On Wednesday, January 24, 2024 8:41:57 AM CET Philippe Mathieu-Daudé 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>
> ---

Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

>  hw/9pfs/9p-synth.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
> index 0ac79a500b..419ea69e3a 100644
> --- a/hw/9pfs/9p-synth.c
> +++ b/hw/9pfs/9p-synth.c
> @@ -241,15 +241,15 @@ static struct dirent *synth_get_dentry(V9fsSynthNode *dir,
>      int i = 0;
>      V9fsSynthNode *node;
>  
> -    rcu_read_lock();
> -    QLIST_FOREACH(node, &dir->child, sibling) {
> -        /* This is the off child of the directory */
> -        if (i == off) {
> -            break;
> +    WITH_RCU_READ_LOCK_GUARD() {
> +        QLIST_FOREACH(node, &dir->child, sibling) {
> +            /* This is the off child of the directory */
> +            if (i == off) {
> +                break;
> +            }
> +            i++;
>          }
> -        i++;
>      }
> -    rcu_read_unlock();
>      if (!node) {
>          /* end of directory */
>          return NULL;
> @@ -494,13 +494,13 @@ static int synth_name_to_path(FsContext *ctx, V9fsPath *dir_path,
>          goto out;
>      }
>      /* search for the name in the children */
> -    rcu_read_lock();
> -    QLIST_FOREACH(node, &dir_node->child, sibling) {
> -        if (!strcmp(node->name, name)) {
> -            break;
> +    WITH_RCU_READ_LOCK_GUARD() {
> +        QLIST_FOREACH(node, &dir_node->child, sibling) {
> +            if (!strcmp(node->name, name)) {
> +                break;
> +            }
>          }
>      }
> -    rcu_read_unlock();
>  
>      if (!node) {
>          errno = ENOENT;
> 
Re: [PATCH 2/6] hw/9pfs/9p-synth: Use RCU_READ macro
Posted by Greg Kurz 10 months, 1 week ago
On Wed, 24 Jan 2024 08:41:57 +0100
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/9pfs/9p-synth.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 

Acked-by: Greg Kurz <groug@kaod.org>

> diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
> index 0ac79a500b..419ea69e3a 100644
> --- a/hw/9pfs/9p-synth.c
> +++ b/hw/9pfs/9p-synth.c
> @@ -241,15 +241,15 @@ static struct dirent *synth_get_dentry(V9fsSynthNode *dir,
>      int i = 0;
>      V9fsSynthNode *node;
>  
> -    rcu_read_lock();
> -    QLIST_FOREACH(node, &dir->child, sibling) {
> -        /* This is the off child of the directory */
> -        if (i == off) {
> -            break;
> +    WITH_RCU_READ_LOCK_GUARD() {
> +        QLIST_FOREACH(node, &dir->child, sibling) {
> +            /* This is the off child of the directory */
> +            if (i == off) {
> +                break;
> +            }
> +            i++;
>          }
> -        i++;
>      }
> -    rcu_read_unlock();
>      if (!node) {
>          /* end of directory */
>          return NULL;
> @@ -494,13 +494,13 @@ static int synth_name_to_path(FsContext *ctx, V9fsPath *dir_path,
>          goto out;
>      }
>      /* search for the name in the children */
> -    rcu_read_lock();
> -    QLIST_FOREACH(node, &dir_node->child, sibling) {
> -        if (!strcmp(node->name, name)) {
> -            break;
> +    WITH_RCU_READ_LOCK_GUARD() {
> +        QLIST_FOREACH(node, &dir_node->child, sibling) {
> +            if (!strcmp(node->name, name)) {
> +                break;
> +            }
>          }
>      }
> -    rcu_read_unlock();
>  
>      if (!node) {
>          errno = ENOENT;



-- 
Greg