Skip to contentSkip to conversation

LOCK GUARDS: replace manual lock()/unlock() calls to QEMU_LOCK_GUARD()

PATCH In review [email protected] 3 participants 4 messages Nov 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LOCK GUARDS: replace manual lock()/unlock() calls to QEMU_LOCK_GUARD()

From: Samker <[email protected]>

This is patch replaces WITH_QEMU_LOCK_GUARD() call with the QEMU_LOCK_GUARD()

---
 softmmu/physmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
softmmu/physmem.c +2 -2
index fb00596777..907491ae17 100644
@@ -3115,7 +3115,7 @@ void cpu_register_map_client(QEMUBH *bh)
 {
     MapClient *client = g_malloc(sizeof(*client));
 
-    WITH_QEMU_LOCK_GUARD(&map_client_list_lock);
+    QEMU_LOCK_GUARD(&map_client_list_lock);
     client->bh = bh;
     QLIST_INSERT_HEAD(&map_client_list, client, link);
     if (!qatomic_read(&bounce.in_use)) {
@@ -3143,7 +3143,7 @@ void cpu_unregister_map_client(QEMUBH *bh)
 {
     MapClient *client;
 
-    WITH_QEMU_LOCK_GUARD(&map_client_list_lock);
+    QEMU_LOCK_GUARD(&map_client_list_lock);
     QLIST_FOREACH(client, &map_client_list, link) {
         if (client->bh == bh) {
             cpu_unregister_map_client_do(client);
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 24 lines · On 8/11/22 06:11, [email protected] wrote:

From: Samker <[email protected]>

This is patch replaces WITH_QEMU_LOCK_GUARD() call with the QEMU_LOCK_GUARD()

---
  softmmu/physmem.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
softmmu/physmem.c +1 -1
index fb00596777..907491ae17 100644
@@ -3115,7 +3115,7 @@ void cpu_register_map_client(QEMUBH *bh)
  {
      MapClient *client = g_malloc(sizeof(*client));
 
-    WITH_QEMU_LOCK_GUARD(&map_client_list_lock);
+    QEMU_LOCK_GUARD(&map_client_list_lock);
      client->bh = bh;
      QLIST_INSERT_HEAD(&map_client_list, client, link);
      if (!qatomic_read(&bounce.in_use)) {

softmmu/physmem.c void cpu_unregister_map_client(QEMUBH *bh) · line 3149

Quoted 8 lines
softmmu/physmem.c +1 -1
@@ -3143,7 +3143,7 @@ void cpu_unregister_map_client(QEMUBH *bh)
  {
      MapClient *client;
 
-    WITH_QEMU_LOCK_GUARD(&map_client_list_lock);
+    QEMU_LOCK_GUARD(&map_client_list_lock);
      QLIST_FOREACH(client, &map_client_list, link) {
          if (client->bh == bh) {
              cpu_unregister_map_client_do(client);

This patch doesn't apply...

$ git grep QEMU_LOCK_GUARD origin/master -- softmmu/physmem.c
$

On what is it based?

#2 lore raw

Hi Philippe,

Quoted 7 lines

This patch doesn't apply...

$ git grep QEMU_LOCK_GUARD origin/master -- softmmu/physmem.c

$

On what is it based?

I initially replaced lock()/unlock() calls in the softmmu/physmem.c with the more preferred WITH_QEMU_LOCK_GUARD() call.

However Stefan pointed out that instead I should have used QEMU_LOCK_GUARD when I don't want to use block scope.

Reviewed-by on v1 1/1
#3 lore raw
In reply to [email protected]
Quoted 4 lines · [email protected] writes:

From: Samker <[email protected]>

This is patch replaces WITH_QEMU_LOCK_GUARD() call with the QEMU_LOCK_GUARD()

You could extend this description as to why ".. because it extends the scope of the lock to the whole function rather than the non-existent block".

Otherwise:

Quoted 28 lines
---
 softmmu/physmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
softmmu/physmem.c +2 -2
index fb00596777..907491ae17 100644
@@ -3115,7 +3115,7 @@ void cpu_register_map_client(QEMUBH *bh)
 {
     MapClient *client = g_malloc(sizeof(*client));
 
-    WITH_QEMU_LOCK_GUARD(&map_client_list_lock);
+    QEMU_LOCK_GUARD(&map_client_list_lock);
     client->bh = bh;
     QLIST_INSERT_HEAD(&map_client_list, client, link);
     if (!qatomic_read(&bounce.in_use)) {
@@ -3143,7 +3143,7 @@ void cpu_unregister_map_client(QEMUBH *bh)
 {
     MapClient *client;
 
-    WITH_QEMU_LOCK_GUARD(&map_client_list_lock);
+    QEMU_LOCK_GUARD(&map_client_list_lock);
     QLIST_FOREACH(client, &map_client_list, link) {
         if (client->bh == bh) {
             cpu_unregister_map_client_do(client);
Signature · 1 line
Alex Bennée