Skip to contentSkip to conversation

migration/block: Avoid invoking blk_drain too frequently

PATCH In review Lidong Chen 5 participants 6 messages Mar 15, 2017 – Mar 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 migration/block: Avoid invoking blk_drain too frequently

Increase bmds->cur_dirty after submit io, so reduce the frequency involve into blk_drain, and improve the performance obviously when block migration.

The performance test result of this patch:

During the block dirty save phase, this patch improve guest os IOPS from 4.0K to 9.5K. and improve the migration speed from 505856 rsec/s to 855756 rsec/s.

---
 migration/block.c | 3 +++
 1 file changed, 3 insertions(+)
migration/block.c +3 -0
index 6741228..7734ff7 100644
@@ -576,6 +576,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
             }
 
             bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+            sector += nr_sectors;
+            bmds->cur_dirty = sector;
+
             break;
         }
         sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#1 lore raw

Am 15.03.2017 um 04:37 hat Lidong Chen geschrieben:

Quoted 20 lines

Increase bmds->cur_dirty after submit io, so reduce the frequency involve into blk_drain, and improve the performance obviously when block migration.

The performance test result of this patch:

During the block dirty save phase, this patch improve guest os IOPS from 4.0K to 9.5K. and improve the migration speed from 505856 rsec/s to 855756 rsec/s.

---
 migration/block.c | 3 +++
 1 file changed, 3 insertions(+)
migration/block.c +0 -0
index 6741228..7734ff7 100644

migration/block.c static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, · line 579

Quoted 4 lines
migration/block.c +1 -0
@@ -576,6 +576,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
             }
 
             bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+            sector += nr_sectors;

sector += BDRV_SECTORS_PER_DIRTY_CHUNK would be acceptable here...

Quoted 7 lines
migration/block.c +2 -0
+            bmds->cur_dirty = sector;
+
             break;
         }
         sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
         bmds->cur_dirty = sector;
     }

...which would make it the same code as the rest of the loop. It could be nicer to reuse the same code and just set a bool when a request is submitted so that the loop terminates after that.

But that's just a matter of taste, so I'll still give:

Reviewed-by on v2 1/1
#2 lore raw
In reply to Lidong Chen
Quoted 32 lines · Lidong Chen

Increase bmds->cur_dirty after submit io, so reduce the frequency involve into blk_drain, and improve the performance obviously when block migration.

The performance test result of this patch:

During the block dirty save phase, this patch improve guest os IOPS from 4.0K to 9.5K. and improve the migration speed from 505856 rsec/s to 855756 rsec/s.

---
 migration/block.c | 3 +++
 1 file changed, 3 insertions(+)
migration/block.c +3 -0
index 6741228..7734ff7 100644
@@ -576,6 +576,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
             }
 
             bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+            sector += nr_sectors;
+            bmds->cur_dirty = sector;
+
             break;
         }
         sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
Signature · 1 line
1.8.3.1

Nice catch above all, thank you!

#3 lore raw
Quoted 36 lines · * Fam Zheng ([email protected]) wrote:
Quoted 32 lines · Lidong Chen

Increase bmds->cur_dirty after submit io, so reduce the frequency involve into blk_drain, and improve the performance obviously when block migration.

The performance test result of this patch:

During the block dirty save phase, this patch improve guest os IOPS from 4.0K to 9.5K. and improve the migration speed from 505856 rsec/s to 855756 rsec/s.

---
 migration/block.c | 3 +++
 1 file changed, 3 insertions(+)
migration/block.c +3 -0
index 6741228..7734ff7 100644
@@ -576,6 +576,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
             }
 
             bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+            sector += nr_sectors;
+            bmds->cur_dirty = sector;
+
             break;
         }
         sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
Signature · 1 line
1.8.3.1

Nice catch above all, thank you!

Quoted 1 line

Are you taking that via a block pull?

Dave
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw
Quoted 37 lines · Dr. David Alan Gilbert
Quoted 36 lines · * Fam Zheng ([email protected]) wrote:
Quoted 32 lines · Lidong Chen

Increase bmds->cur_dirty after submit io, so reduce the frequency involve into blk_drain, and improve the performance obviously when block migration.

The performance test result of this patch:

During the block dirty save phase, this patch improve guest os IOPS from 4.0K to 9.5K. and improve the migration speed from 505856 rsec/s to 855756 rsec/s.

---
 migration/block.c | 3 +++
 1 file changed, 3 insertions(+)
migration/block.c +3 -0
index 6741228..7734ff7 100644
@@ -576,6 +576,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
             }
 
             bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+            sector += nr_sectors;
+            bmds->cur_dirty = sector;
+
             break;
         }
         sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
Signature · 1 line
1.8.3.1

Nice catch above all, thank you!

Quoted 3 lines
Quoted 1 line

Are you taking that via a block pull?

I can do that, but I'm not sure whether it should go to 2.9. This is a performance improvement, which usually doesn't qualify as bug fixes. But this also looks like a mistake in original code.

Fam

#5 lore raw
Quoted 40 lines · Fam Zheng
Quoted 39 lines · Dr. David Alan Gilbert
Quoted 37 lines · * Fam Zheng ([email protected]) wrote:
Quoted 32 lines · Lidong Chen

Increase bmds->cur_dirty after submit io, so reduce the frequency involve into blk_drain, and improve the performance obviously when block migration.

The performance test result of this patch:

During the block dirty save phase, this patch improve guest os IOPS from 4.0K to 9.5K. and improve the migration speed from 505856 rsec/s to 855756 rsec/s.

---
 migration/block.c | 3 +++
 1 file changed, 3 insertions(+)
migration/block.c +3 -0
index 6741228..7734ff7 100644
@@ -576,6 +576,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
             }
 
             bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
+            sector += nr_sectors;
+            bmds->cur_dirty = sector;
+
             break;
         }
         sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
Signature · 1 line
1.8.3.1

Nice catch above all, thank you!

Quoted 7 lines
Quoted 1 line

Are you taking that via a block pull?

I can do that, but I'm not sure whether it should go to 2.9. This is a performance improvement, which usually doesn't qualify as bug fixes. But this also looks like a mistake in original code.

Fam

I am taking it through migration and push it. I agree with your description.