Fixups for non-migratable RAMBlocks
cover Fixups for non-migratable RAMBlocks
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
Cédric's b895de50 got merged at about the same
time as some of Peter's changes and there's a rdma case as well; so tidy up those cases that were looping over all (rather than just migratable) RAMBlocks and poison it so we don't end up doing the same thing again.
Dave
Dr. David Alan Gilbert (2):
migration: Fixes for non-migratable RAMBlocks
migration: Poison ramblock loops in migration
include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 8 +++++--- migration/rdma.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.0
PATCH 1/2 migration: Fixes for non-migratable RAMBlocks
From: "Dr. David Alan Gilbert" <[email protected]>
There are still a few cases where migration code is using the macros and functions that do all RAMBlocks rather than just the migratable blocks; fix those up.
--- migration/ram.c | 4 ++-- migration/rdma.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
migration/ram.c +2 -2
@@ -2516,7 +2516,7 @@ static void ram_state_resume_prepare(RAMState *rs, QEMUFile *out)* about dirty page logging as well. */ -RAMBLOCK_FOREACH (block) { +RAMBLOCK_FOREACH_MIGRATABLE (block) { pages +=bitmap_count_one (block->bmap, block->used_length >>TARGET_PAGE_BITS ); }
@@ -3431,7 +3431,7 @@ static int ram_dirty_bitmap_sync_all(MigrationState *s, RAMState *rs)trace_ram_dirty_bitmap_sync_start (); -RAMBLOCK_FOREACH (block) { +RAMBLOCK_FOREACH_MIGRATABLE (block) {qemu_savevm_send_recv_bitmap (file, block->idstr);trace_ram_dirty_bitmap_request (block->idstr); ramblock_count++;
migration/rdma.c +1 -1
@@ -635,7 +635,7 @@ static int qemu_rdma_init_ram_blocks(RDMAContext *rdma)assert (rdma->blockmap ==NULL );memset (local,0 ,sizeof *local); -qemu_ram_foreach_block (qemu_rdma_init_one_block, rdma); +qemu_ram_foreach_migratable_block (qemu_rdma_init_one_block, rdma);trace_qemu_rdma_init_ram_blocks (local->nb_blocks); rdma->dest_blocks =g_new0 (RDMADestBlock, rdma->local_ram_blocks.nb_blocks);
Signature · 1 line
2.17.0
Re: [Qemu-devel] [PATCH 1/2] migration: Fixes for non-migratable RAMBlocks
Quoted 7 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
There are still a few cases where migration code is using the macros and functions that do all RAMBlocks rather than just the migratable blocks; fix those up.
Signed-off-by Dr. David Alan Gilbert <[email protected]>
Indeed...
Thanks,
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 1/2] migration: Fixes for non-migratable RAMBlocks
In reply to Dr. David Alan Gilbert (git)Quoted 7 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
There are still a few cases where migration code is using the macros and functions that do all RAMBlocks rather than just the migratable blocks; fix those up.
Signed-off-by Dr. David Alan Gilbert <[email protected]>
Thanks,
C.
Quoted 41 lines
--- migration/ram.c | 4 ++-- migration/rdma.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)migration/ram.c +2
-2@@ -2516,7 +2516,7 @@ static void ram_state_resume_prepare(RAMState *rs, QEMUFile *out)* about dirty page logging as well. */ -RAMBLOCK_FOREACH (block) { +RAMBLOCK_FOREACH_MIGRATABLE (block) { pages +=bitmap_count_one (block->bmap, block->used_length >>TARGET_PAGE_BITS ); }@@ -3431,7 +3431,7 @@ static int ram_dirty_bitmap_sync_all(MigrationState *s, RAMState *rs)trace_ram_dirty_bitmap_sync_start (); -RAMBLOCK_FOREACH (block) { +RAMBLOCK_FOREACH_MIGRATABLE (block) {qemu_savevm_send_recv_bitmap (file, block->idstr);trace_ram_dirty_bitmap_request (block->idstr); ramblock_count++;migration/rdma.c +1
-1@@ -635,7 +635,7 @@ static int qemu_rdma_init_ram_blocks(RDMAContext *rdma)assert (rdma->blockmap ==NULL );memset (local,0 ,sizeof *local); -qemu_ram_foreach_block (qemu_rdma_init_one_block, rdma); +qemu_ram_foreach_migratable_block (qemu_rdma_init_one_block, rdma);trace_qemu_rdma_init_ram_blocks (local->nb_blocks); rdma->dest_blocks =g_new0 (RDMADestBlock, rdma->local_ram_blocks.nb_blocks);
PATCH 2/2 migration: Poison ramblock loops in migration
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
The migration code should be using the
RAMBLOCK_FOREACH_MIGRATABLE and qemu_ram_foreach_block_migratable
not the all-block versions; poison them so that we can't accidentally use them.
--- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-)
include/exec/ramlist.h +3 -1
@@ -56,8 +56,10 @@ typedef struct RAMList {extern RAMList ram_list;/* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH (block) \ +#define INTERNAL_RAMBLOCK_FOREACH (block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH (block) INTERNAL_RAMBLOCK_FOREACH(block)void qemu_mutex_lock_ramlist (void );void qemu_mutex_unlock_ramlist (void );
migration/migration.h +3 -0
@@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);void dirty_bitmap_mig_before_vm_start (void );void init_dirty_bitmap_incoming_migration (void ); +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" +#endif
migration/ram.c +3 -1
@@ -159,9 +159,11 @@ out:/* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE (block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else +#undef RAMBLOCK_FOREACH +static void ramblock_recv_map_init (void ) {RAMBlock *rb;
Signature · 1 line
2.17.0
A message that is not in the archive (sent off-list or not yet received): 20180606033600.GA2606@xz-mi
Re: [Qemu-devel] [PATCH 2/2] migration: Poison ramblock loops in migration
Quoted 55 lines · Peter Xu
Quoted 54 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The migration code should be using the
RAMBLOCK_FOREACH_MIGRATABLEandqemu_ram_foreach_block_migratable
not the all-block versions; poison them so that we can't accidentally use them.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-)include/exec/ramlist.h +3
-1@@ -56,8 +56,10 @@ typedef struct RAMList {extern RAMList ram_list;/* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH (block) \ +#define INTERNAL_RAMBLOCK_FOREACH (block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH (block) INTERNAL_RAMBLOCK_FOREACH(block)void qemu_mutex_lock_ramlist (void );void qemu_mutex_unlock_ramlist (void );migration/migration.h +3
-0@@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);void dirty_bitmap_mig_before_vm_start (void );void init_dirty_bitmap_incoming_migration (void ); +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" +#endif migration/ram.c +1
-1@@ -159,9 +159,11 @@ out:/* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE (block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else
Quoted 7 lines
migration/ram.c out: · line 165
Quoted 1 line
migration/ram.c +1
-0+#undef RAMBLOCK_FOREACHThis will only cover the
ram.cfile. How about we moveRAMBLOCK_FOREACH_MIGRATABLE()directly intomigration.hthen undefRAMBLOCK_FOREACHthere? Then sincemigration.hshould be used in all the migration internal source files so the poisoned bit can be used in a broader aspect?
(I forgot to reply-all.... forwarding to the list)
Quoted 13 lines
Thanks,
Quoted 7 lines
migration/ram.c +1
-0+static void ramblock_recv_map_init (void ) {RAMBlock *rb;Signature · 1 line
2.17.0Signature · 1 line
Peter Xu
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 2/2] migration: Poison ramblock loops in migration
Quoted 64 lines · * Peter Xu ([email protected]) wrote:
Quoted 55 lines · Peter Xu
Quoted 54 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The migration code should be using the
RAMBLOCK_FOREACH_MIGRATABLEandqemu_ram_foreach_block_migratable
not the all-block versions; poison them so that we can't accidentally use them.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-)include/exec/ramlist.h +3
-1@@ -56,8 +56,10 @@ typedef struct RAMList {extern RAMList ram_list;/* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH (block) \ +#define INTERNAL_RAMBLOCK_FOREACH (block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH (block) INTERNAL_RAMBLOCK_FOREACH(block)void qemu_mutex_lock_ramlist (void );void qemu_mutex_unlock_ramlist (void );migration/migration.h +3
-0@@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);void dirty_bitmap_mig_before_vm_start (void );void init_dirty_bitmap_incoming_migration (void ); +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" +#endif migration/ram.c +1
-1@@ -159,9 +159,11 @@ out:/* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE (block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} elseQuoted 7 lines
migration/ram.c out: · line 165
Quoted 1 line
migration/ram.c +1
-0+#undef RAMBLOCK_FOREACHThis will only cover the
ram.cfile. How about we moveRAMBLOCK_FOREACH_MIGRATABLE()directly intomigration.hthen undefRAMBLOCK_FOREACHthere? Then sincemigration.hshould be used in all the migration internal source files so the poisoned bit can be used in a broader aspect?
Quoted 1 line
(I forgot to reply-all.... forwarding to the list)
Yes, we could; although it's only the ram.c that's compiled
target specific and can include the header that allows use of those macros anyway.
Dave
Quoted 11 lines
Quoted 11 lines
Thanks,
Quoted 7 lines
migration/ram.c +1
-0+static void ramblock_recv_map_init (void ) {RAMBlock *rb;Signature · 1 line
2.17.0
Quoted 5 lines
Quoted 2 lines
Signature · 1 line
Peter XuSignature · 1 line
Peter Xu
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Peter Xu
Reviewed-byRe: [Qemu-devel] [PATCH 2/2] migration: Poison ramblock loops in migration
Quoted 65 lines · Dr. David Alan Gilbert
Quoted 64 lines · * Peter Xu ([email protected]) wrote:
Quoted 62 lines · Peter Xu
Quoted 47 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The migration code should be using the
RAMBLOCK_FOREACH_MIGRATABLEandqemu_ram_foreach_block_migratable
not the all-block versions; poison them so that we can't accidentally use them.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-)include/exec/ramlist.h +3
-1@@ -56,8 +56,10 @@ typedef struct RAMList {extern RAMList ram_list;/* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH (block) \ +#define INTERNAL_RAMBLOCK_FOREACH (block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH (block) INTERNAL_RAMBLOCK_FOREACH(block)void qemu_mutex_lock_ramlist (void );void qemu_mutex_unlock_ramlist (void );migration/migration.h +3
-0@@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);void dirty_bitmap_mig_before_vm_start (void );void init_dirty_bitmap_incoming_migration (void ); +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" +#endif migration/ram.c +0
-0migration/ram.c out: · line 165
Quoted 8 lines
migration/ram.c +2
-1@@ -159,9 +159,11 @@ out:/* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE (block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else +#undef RAMBLOCK_FOREACHThis will only cover the
ram.cfile. How about we moveRAMBLOCK_FOREACH_MIGRATABLE()directly intomigration.hthen undefRAMBLOCK_FOREACHthere? Then sincemigration.hshould be used in all the migration internal source files so the poisoned bit can be used in a broader aspect?
Quoted 4 lines
Quoted 1 line
(I forgot to reply-all.... forwarding to the list)
Yes, we could; although it's only the
ram.cthat's compiled
target specific and can include the header that allows use of those macros anyway.
Yes, ram.c seems to be the only user. Then I'm fine with the patch:
Thanks,
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 2/2] migration: Poison ramblock loops in migration
In reply to Dr. David Alan Gilbert (git)Quoted 8 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The migration code should be using the
RAMBLOCK_FOREACH_MIGRATABLEandqemu_ram_foreach_block_migratable
not the all-block versions; poison them so that we can't accidentally use them.Signed-off-by Dr. David Alan Gilbert <[email protected]>
Thanks,
C.
Quoted 52 lines
--- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-)include/exec/ramlist.h +3
-1@@ -56,8 +56,10 @@ typedef struct RAMList {extern RAMList ram_list;/* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH (block) \ +#define INTERNAL_RAMBLOCK_FOREACH (block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH (block) INTERNAL_RAMBLOCK_FOREACH(block)void qemu_mutex_lock_ramlist (void );void qemu_mutex_unlock_ramlist (void );migration/migration.h +3
-0@@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value);void dirty_bitmap_mig_before_vm_start (void );void init_dirty_bitmap_incoming_migration (void ); +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" +#endif migration/ram.c +3
-1@@ -159,9 +159,11 @@ out:/* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE (block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else +#undef RAMBLOCK_FOREACH +static void ramblock_recv_map_init (void ) {RAMBlock *rb;
Quoted 9 lines · * Dr. David Alan Gilbert (git) ([email protected]) wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
Cédric'sb895de50got merged at about the same
time as some of Peter's changes and there's a rdma case as well; so tidy up those cases that were looping over all (rather than just migratable) RAMBlocks and poison it so we don't end up doing the same thing again.
Queued.
Quoted 6 lines
Dave
Dr. David Alan Gilbert (2):
migration: Fixes for non-migratable RAMBlocks
migration: Poison ramblock loops in migration
Quoted 10 lines
include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 8 +++++--- migration/rdma.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-)Signature · 1 line
2.17.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK