From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: quintela@redhat.com
Cc: kwolf@redhat.com, fam@euphon.net, qemu-block@nongnu.org,
dgilbert@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
mreitz@redhat.com, jsnow@redhat.com
Subject: Re: [PATCH 1/7] migration/block-dirty-bitmap: refactor incoming state to be one struct
Date: Tue, 11 Feb 2020 18:03:41 +0300 [thread overview]
Message-ID: <dbbbfaf4-1fb6-d952-df1c-3303039fe2f4@virtuozzo.com> (raw)
In-Reply-To: <87eevp5dib.fsf@secure.laptop>
24.01.2020 13:56, Juan Quintela wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
>> Move enabled_bitmaps and finish_lock, which are part of incoming state
>> to DirtyBitmapLoadState, and make static global variable to store state
>> instead of static local one.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>> migration/block-dirty-bitmap.c | 77 +++++++++++++++++++---------------
>> 1 file changed, 43 insertions(+), 34 deletions(-)
>>
>> diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
>> index 7eafface61..281d20f41d 100644
>> --- a/migration/block-dirty-bitmap.c
>> +++ b/migration/block-dirty-bitmap.c
>> @@ -125,6 +125,13 @@ typedef struct DirtyBitmapMigState {
>> BlockDriverState *prev_bs;
>> BdrvDirtyBitmap *prev_bitmap;
>> } DirtyBitmapMigState;
>> +static DirtyBitmapMigState dirty_bitmap_mig_state;
>
> Missing new line.
>
>> +
>> +typedef struct DirtyBitmapLoadBitmapState {
>> + BlockDriverState *bs;
>> + BdrvDirtyBitmap *bitmap;
>> + bool migrated;
>> +} DirtyBitmapLoadBitmapState;
>>
>> typedef struct DirtyBitmapLoadState {
>> uint32_t flags;
>> @@ -132,21 +139,15 @@ typedef struct DirtyBitmapLoadState {
>> char bitmap_name[256];
>> BlockDriverState *bs;
>> BdrvDirtyBitmap *bitmap;
>> -} DirtyBitmapLoadState;
>>
>> -static DirtyBitmapMigState dirty_bitmap_mig_state;
>> -
>> -typedef struct DirtyBitmapLoadBitmapState {
>> - BlockDriverState *bs;
>> - BdrvDirtyBitmap *bitmap;
>> - bool migrated;
>> -} DirtyBitmapLoadBitmapState;
>> -static GSList *enabled_bitmaps;
>> -QemuMutex finish_lock;
>> + GSList *enabled_bitmaps;
>> + QemuMutex finish_lock;
>> +} DirtyBitmapLoadState;
>> +static DirtyBitmapLoadState dbm_load_state;
>
> You move two global variables to an struct (good)
> But you create a even bigger global variable (i.e. state that was not
> shared before.)
>
>> /* First occurrence of this bitmap. It should be created if doesn't exist */
>> -static int dirty_bitmap_load_start(QEMUFile *f, DirtyBitmapLoadState *s)
>> +static int dirty_bitmap_load_start(QEMUFile *f)
>> {
>> + DirtyBitmapLoadState *s = &dbm_load_state;
>
> You create a local alias.
>
>> Error *local_err = NULL;
>> uint32_t granularity = qemu_get_be32(f);
>> uint8_t flags = qemu_get_byte(f);
>> @@ -482,7 +484,8 @@ static int dirty_bitmap_load_start(QEMUFile *f, DirtyBitmapLoadState *s)
>> b->bs = s->bs;
>> b->bitmap = s->bitmap;
>> b->migrated = false;
>> - enabled_bitmaps = g_slist_prepend(enabled_bitmaps, b);
>> + dbm_load_state.enabled_bitmaps =
>> + g_slist_prepend(dbm_load_state.enabled_bitmaps, b);
>
> And then you access it using the global variable?
>
>> -static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *s)
>> +static void dirty_bitmap_load_complete(QEMUFile *f)
>> {
>> + DirtyBitmapLoadState *s = &dbm_load_state;
>
> Exactly the same on this function.
>
> I still don't understand why you are removing the pass as parameters of
> this function.
>
>
>> - static DirtyBitmapLoadState s;
>
> Aha, this is why you are moving it as a global.
>
> But, why can't you put this inside dirty_bitmap_mig_state? Then you:
> a- don't have to have "yet" another global variable
> b- you can clean it up on save_cleanup handler.
Because dirty_bitmap_mig_state is source state, and new dbm_load_state is
destination state. So, at least [b] will not work...
Do you think it's good to combine both source and destination states into one
struct, and use opaque everywhere?
It will look like
DirtyBitmapMigSourceState *s = ((DirtyBitmapMigState *)opaque)->source_state;
in save functions
and
DirtyBitmapIncomingState *s = ((DirtyBitmapMigState *)opaque)->incoming_state;
in load function
>
> not related to this patch, but to the file in general:
>
> static void dirty_bitmap_save_cleanup(void *opaque)
> {
> dirty_bitmap_mig_cleanup();
> }
>
> We have opaque here, that we can do:
>
> DirtyBitmapMigBitmapState *dbms = opaque;
>
> And then pass dbms to dirty_bitmap_mig_cleanup().
>
> /* Called with iothread lock taken. */
> static void dirty_bitmap_mig_cleanup(void)
> {
> DirtyBitmapMigBitmapState *dbms;
>
> while ((dbms = QSIMPLEQ_FIRST(&dirty_bitmap_mig_state.dbms_list)) != NULL) {
> QSIMPLEQ_REMOVE_HEAD(&dirty_bitmap_mig_state.dbms_list, entry);
> bdrv_dirty_bitmap_set_busy(dbms->bitmap, false);
> bdrv_unref(dbms->bs);
> g_free(dbms);
> }
> }
>
>
> Because here we just use the global variable.
>
> Later, Juan.
>
--
Best regards,
Vladimir
next prev parent reply other threads:[~2020-02-11 15:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 13:23 [PATCH 0/7] Fix crashes on early shutdown during bitmaps postcopy Vladimir Sementsov-Ogievskiy
2020-01-22 13:23 ` [PATCH 1/7] migration/block-dirty-bitmap: refactor incoming state to be one struct Vladimir Sementsov-Ogievskiy
2020-01-24 10:56 ` Juan Quintela
2020-02-11 15:03 ` Vladimir Sementsov-Ogievskiy [this message]
2020-01-22 13:23 ` [PATCH 2/7] migration/block-dirty-bitmap: rename finish_lock to just lock Vladimir Sementsov-Ogievskiy
2020-01-24 10:57 ` Juan Quintela
2020-01-22 13:23 ` [PATCH 3/7] migration/block-dirty-bitmap: simplify dirty_bitmap_load_complete Vladimir Sementsov-Ogievskiy
2020-01-22 13:23 ` [PATCH 4/7] migration/block-dirty-bitmap: keep bitmap state for all bitmaps Vladimir Sementsov-Ogievskiy
2020-01-24 11:01 ` Juan Quintela
2020-02-11 15:12 ` Vladimir Sementsov-Ogievskiy
2020-02-11 15:14 ` Vladimir Sementsov-Ogievskiy
2020-01-22 13:23 ` [PATCH 5/7] migration/block-dirty-bitmap: cancel migration on shutdown Vladimir Sementsov-Ogievskiy
2020-01-22 13:23 ` [PATCH 6/7] migration: handle to_src_file on target only for ram postcopy Vladimir Sementsov-Ogievskiy
2020-01-22 13:23 ` [PATCH 7/7] qemu-iotests/199: add early shutdown case to bitmaps postcopy Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dbbbfaf4-1fb6-d952-df1c-3303039fe2f4@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=dgilbert@redhat.com \
--cc=fam@euphon.net \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).