diff mbox

[for-2.5] block-migration: limit the memory usage

Message ID 564EE9C9.6000707@cn.fujitsu.com
State New
Headers show

Commit Message

Wen Congyang Nov. 20, 2015, 9:37 a.m. UTC
If we set migration speed in a very large value, block-migration will try to read
all data to the memory. Because
    (block_mig_state.submitted + block_mig_state.read_done) * BLOCK_SIZE
will be overflow, and it will be always less than rate limit.

There is no need to read too many data into memory when the rate limit is very large.
So limit the memory usage can fix the overflow problem.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 migration/block.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Juan Quintela Nov. 23, 2015, 4:31 p.m. UTC | #1
Wen Congyang <wency@cn.fujitsu.com> wrote:
> If we set migration speed in a very large value, block-migration will try to read
> all data to the memory. Because
>     (block_mig_state.submitted + block_mig_state.read_done) * BLOCK_SIZE
> will be overflow, and it will be always less than rate limit.
>
> There is no need to read too many data into memory when the rate limit is very large.
> So limit the memory usage can fix the overflow problem.
>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

If no block layer maintainer objects, I will apply this to my tree.

Later, Juan.
Stefan Hajnoczi Nov. 24, 2015, 4:47 a.m. UTC | #2
On Mon, Nov 23, 2015 at 05:31:33PM +0100, Juan Quintela wrote:
> Wen Congyang <wency@cn.fujitsu.com> wrote:
> > If we set migration speed in a very large value, block-migration will try to read
> > all data to the memory. Because
> >     (block_mig_state.submitted + block_mig_state.read_done) * BLOCK_SIZE
> > will be overflow, and it will be always less than rate limit.
> >
> > There is no need to read too many data into memory when the rate limit is very large.
> > So limit the memory usage can fix the overflow problem.
> >
> > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> 
> Reviewed-by: Juan Quintela <quintela@redhat.com>
> 
> If no block layer maintainer objects, I will apply this to my tree.
> 
> Later, Juan.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/migration/block.c b/migration/block.c
index 310e2b3..656f38f 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -36,6 +36,8 @@ 
 
 #define MAX_IS_ALLOCATED_SEARCH 65536
 
+#define MAX_INFLIGHT_IO 512
+
 //#define DEBUG_BLK_MIGRATION
 
 #ifdef DEBUG_BLK_MIGRATION
@@ -665,7 +667,10 @@  static int block_save_iterate(QEMUFile *f, void *opaque)
     blk_mig_lock();
     while ((block_mig_state.submitted +
             block_mig_state.read_done) * BLOCK_SIZE <
-           qemu_file_get_rate_limit(f)) {
+           qemu_file_get_rate_limit(f) &&
+           (block_mig_state.submitted +
+            block_mig_state.read_done) <
+           MAX_INFLIGHT_IO) {
         blk_mig_unlock();
         if (block_mig_state.bulk_completed == 0) {
             /* first finish the bulk phase */