diff mbox series

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

Message ID 20240425114207.54148-1-vilhelmgyda@gmail.com (mailing list archive)
State New, archived
Headers show
Series migration/ram.c: API Conversion qemu_mutex_lock(), and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro | expand

Commit Message

Vilhelm Gyda April 25, 2024, 11:42 a.m. UTC
migration/ram.c: API Conversion qemu_mutex_lock(),
and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro

Signed-off-by: Will Gyda <vilhelmgyda@gmail.com>
---
 migration/ram.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Peter Xu April 25, 2024, 1:15 p.m. UTC | #1
On Thu, Apr 25, 2024 at 09:10:34AM -0400, Peter Xu wrote:
> 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

> 
> On Thu, Apr 25, 2024 at 06:08:58PM +0530, Vilhelm Gyda wrote:
> > 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
> 
> > 
> > On Thu, Apr 25, 2024 at 5:12 PM Will Gyda <vilhelmgyda@gmail.com> wrote:
> > >
> > > migration/ram.c: API Conversion qemu_mutex_lock(),
> > > and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro
> > >
> > > Signed-off-by: Will Gyda <vilhelmgyda@gmail.com>
> 
> The patch looks okay:
> 
> Reviewed-by: Peter Xu <peterx@redhat.com>
> 
> Thanks,
> 
> > > ---
> > >  migration/ram.c | 12 ++++++------
> > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/migration/ram.c b/migration/ram.c
> > > index a975c5af16..50df1e9cd2 100644
> > > --- a/migration/ram.c
> > > +++ b/migration/ram.c
> > > @@ -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
> > >
> > 
> 
> -- 
> Peter Xu
Vilhelm Gyda April 25, 2024, 1:28 p.m. UTC | #2
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

On Thu, Apr 25, 2024 at 6:45 PM Peter Xu <peterx@redhat.com> wrote:
>
> On Thu, Apr 25, 2024 at 09:10:34AM -0400, Peter Xu wrote:
> > 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
>
> >
> > On Thu, Apr 25, 2024 at 06:08:58PM +0530, Vilhelm Gyda wrote:
> > > 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
> >
> > >
> > > On Thu, Apr 25, 2024 at 5:12 PM Will Gyda <vilhelmgyda@gmail.com> wrote:
> > > >
> > > > migration/ram.c: API Conversion qemu_mutex_lock(),
> > > > and qemu_mutex_unlock() to WITH_QEMU_LOCK_GUARD macro
> > > >
> > > > Signed-off-by: Will Gyda <vilhelmgyda@gmail.com>
> >
> > The patch looks okay:
> >
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> >
> > Thanks,
> >
> > > > ---
> > > >  migration/ram.c | 12 ++++++------
> > > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/migration/ram.c b/migration/ram.c
> > > > index a975c5af16..50df1e9cd2 100644
> > > > --- a/migration/ram.c
> > > > +++ b/migration/ram.c
> > > > @@ -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
> > > >
> > >
> >
> > --
> > Peter Xu
>
> --
> Peter Xu
>
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index a975c5af16..50df1e9cd2 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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);