Skip to contentSkip to conversation

migration/ram.c: API Conversion qemu_mutex_lock(), and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro

PATCH In review Will Gyda 2 participants 3 messages Apr 25, 2024 2 messages not in the archive

lore
Share & tools
lore

Will Gyda

author
#0 lore raw

PATCH 1/1 migration/ram.c: API Conversion qemu_mutex_lock(), and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro

migration/ram.c: API Conversion qemu_mutex_lock(), and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro

---
 migration/ram.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
migration/ram.c +6 -6
index a975c5af16..50df1e9cd2 100644
@@ -1066,14 +1066,14 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)
     trace_migration_bitmap_sync_start();
     memory_global_dirty_log_sync(last_stage);
 
-    qemu_mutex_lock(&rs->bitmap_mutex);
-    WITH_RCU_READ_LOCK_GUARD() {
-        RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-            ramblock_sync_dirty_bitmap(rs, block);
+    WITH_QEMU_LOCK_GUARD(&rs->bitmap_mutex) {
+        WITH_RCU_READ_LOCK_GUARD() {
+            RAMBLOCK_FOREACH_NOT_IGNORED(block) {
+                ramblock_sync_dirty_bitmap(rs, block);
+            }
+            stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
         }
-        stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
     }
-    qemu_mutex_unlock(&rs->bitmap_mutex);
 
     memory_global_after_dirty_log_sync();
     trace_migration_bitmap_sync_end(rs->num_dirty_pages_period);
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): CADe4k3+GQGSSbbugg-BK6TNp5cJzLSxBTrS0fL3RCfOtV3wx0Q@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): ZipWSkApNVq2SyS9@x1n

#3 lore raw
Quoted 1 line · Peter Xu

Hi,

And I just noticed you didn't copy the list, please normally keep copying the list in replies. So before below links, you can also read this first just in case you still miss some:

https://www.qemu.org/docs/master/devel/submitting-a-patch.html

Quoted 63 lines · Vilhelm Gyda
Quoted 5 lines

Hi, I am new here. This trivial patch is my first contribution. I am not sure who to cc for the review. Checking qemu/MAINTAINERS you guys seemed to be most relevant for this patch. I am looking for what to contribute next, let me know if you guys have any ideas on that. Thanks

Maybe can start with looking at some bugs (see the end of the page below), or todos listed here that you think you have an idea to move on:

https://wiki.qemu.org/ToDo/LiveMigration

Quoted 7 lines · Will Gyda
Quoted 5 lines

migration/ram.c: API Conversion qemu_mutex_lock(), and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro

The patch looks okay:

Thanks,

Quoted 33 lines
Quoted 32 lines
---
 migration/ram.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
migration/ram.c +6 -7
index a975c5af16..50df1e9cd2 100644
@@ -1066,14 +1066,14 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)
     trace_migration_bitmap_sync_start();
     memory_global_dirty_log_sync(last_stage);
 
-    qemu_mutex_lock(&rs->bitmap_mutex);
-    WITH_RCU_READ_LOCK_GUARD() {
-        RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-            ramblock_sync_dirty_bitmap(rs, block);
+    WITH_QEMU_LOCK_GUARD(&rs->bitmap_mutex) {
+        WITH_RCU_READ_LOCK_GUARD() {
+            RAMBLOCK_FOREACH_NOT_IGNORED(block) {
+                ramblock_sync_dirty_bitmap(rs, block);
+            }
+            stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
         }
-        stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
     }
-    qemu_mutex_unlock(&rs->bitmap_mutex);
 
     memory_global_after_dirty_log_sync();
     trace_migration_bitmap_sync_end(rs->num_dirty_pages_period);
--

2.25.1

Signature · 1 line
Peter Xu
Signature · 1 line
Peter Xu
#4 lore raw

Yes, yes. The list will always be cc'd. I found your email after I had already sent on the list, so I omitted the list when I sent it to you. Thanks for the suggestion for further contribution. I am looking at them

Quoted 77 lines · Peter Xu
Quoted 1 line · Peter Xu

Hi,

And I just noticed you didn't copy the list, please normally keep copying the list in replies. So before below links, you can also read this first just in case you still miss some:

https://www.qemu.org/docs/master/devel/submitting-a-patch.html

Quoted 61 lines · Vilhelm Gyda
Quoted 5 lines

Hi, I am new here. This trivial patch is my first contribution. I am not sure who to cc for the review. Checking qemu/MAINTAINERS you guys seemed to be most relevant for this patch. I am looking for what to contribute next, let me know if you guys have any ideas on that. Thanks

Maybe can start with looking at some bugs (see the end of the page below), or todos listed here that you think you have an idea to move on:

https://wiki.qemu.org/ToDo/LiveMigration

Quoted 7 lines · Will Gyda
Quoted 5 lines

migration/ram.c: API Conversion qemu_mutex_lock(), and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro

The patch looks okay:

Thanks,

Quoted 27 lines
Quoted 27 lines
---
 migration/ram.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
migration/ram.c +6 -6
index a975c5af16..50df1e9cd2 100644
@@ -1066,14 +1066,14 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)
     trace_migration_bitmap_sync_start();
     memory_global_dirty_log_sync(last_stage);
 
-    qemu_mutex_lock(&rs->bitmap_mutex);
-    WITH_RCU_READ_LOCK_GUARD() {
-        RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-            ramblock_sync_dirty_bitmap(rs, block);
+    WITH_QEMU_LOCK_GUARD(&rs->bitmap_mutex) {
+        WITH_RCU_READ_LOCK_GUARD() {
+            RAMBLOCK_FOREACH_NOT_IGNORED(block) {
+                ramblock_sync_dirty_bitmap(rs, block);
+            }
+            stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
         }
-        stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
     }
-    qemu_mutex_unlock(&rs->bitmap_mutex);
 
Quoted 6 lines
Quoted 5 lines
migration/ram.c +0 -1
     memory_global_after_dirty_log_sync();
     trace_migration_bitmap_sync_end(rs->num_dirty_pages_period);
--

2.25.1

Quoted 2 lines

--
Peter Xu

--
Peter Xu