From patchwork Wed Nov 25 14:32:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 548596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B3A13140320 for ; Thu, 26 Nov 2015 01:33:55 +1100 (AEDT) Received: from localhost ([::1]:45659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1b8r-0007ua-JB for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2015 09:33:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1b7G-0005K0-SY for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:32:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1b7F-0001UD-Gv for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:32:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1b7F-0001U0-BG for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:32:13 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id BD14BA3B7B; Wed, 25 Nov 2015 14:32:12 +0000 (UTC) Received: from trasno.mitica (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAPEW7AO010347; Wed, 25 Nov 2015 09:32:11 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 25 Nov 2015 15:32:06 +0100 Message-Id: <1448461926-31401-3-git-send-email-quintela@redhat.com> In-Reply-To: <1448461926-31401-1-git-send-email-quintela@redhat.com> References: <1448461926-31401-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com, dgilbert@redhat.com Subject: [Qemu-devel] [PULL 2/2] block-migration: limit the memory usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Wen Congyang 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 Reviewed-by: Juan Quintela Reviewed-by: Stefan Hajnoczi Signed-off-by: Juan Quintela --- migration/block.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 */