From nobody Wed Nov 5 16:56:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536157132529842.3186722954291; Wed, 5 Sep 2018 07:18:52 -0700 (PDT) Received: from localhost ([::1]:56467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxYdk-0003L4-NI for importer@patchew.org; Wed, 05 Sep 2018 10:18:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxYcX-0002ad-2Y for qemu-devel@nongnu.org; Wed, 05 Sep 2018 10:17:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxYcS-0006uP-4Z for qemu-devel@nongnu.org; Wed, 05 Sep 2018 10:17:25 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:46028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxYcR-0006tq-Uu for qemu-devel@nongnu.org; Wed, 05 Sep 2018 10:17:20 -0400 Received: by mail-oi0-x244.google.com with SMTP id t68-v6so13845204oie.12 for ; Wed, 05 Sep 2018 07:17:19 -0700 (PDT) Received: from [192.168.31.103] ([58.35.222.212]) by smtp.gmail.com with ESMTPSA id n84-v6sm1692207oif.23.2018.09.05.07.17.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Sep 2018 07:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=cC1ZlRq7sX/Y97MWuC5DX0coPv69ZSxy+5fmDOGrMXI=; b=AvD+IF830ev9RqRYCruOtnJrT7rS97JJN1Qm1qblvVXeNAP5J6qhrtbrFpmEc4wmyz UmvZw7qe4vHi5pGqeVZtXpuOaU4QwNbK6RWz453Dh5W3TRmVp2mmVxx1KjrYnrs6RQ2C aauLnSgeAuIaov+w8ERMG2Zznnf7VSF7yFSzMwFR/2aOHKOKhcPxqENABrUEN/3vf9Jb P4nY67WlVMi5D1l7vwlGc8eSI//zJH/R92UldwOElXMWpxN7aW+MYm2zhV5hXQQNuFXt ShdkAdQInNnCK5ENE/fNzlPTbz1uyAdk2+6nkwSq6aq2SMZzPRD4dInb9c55kNPSpVuq yuNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=cC1ZlRq7sX/Y97MWuC5DX0coPv69ZSxy+5fmDOGrMXI=; b=Zd7uHeWmzdrG7qmIP5EvsG0uWGXcESq3YQFOixO+Bw/xajkiwb2XRHYYgxAg5fI5JK lXyGecNkEzVBiVkVwk6n/TkUYTfh2lr0k2LiJEtxHv1yhIREIj5LjI8uGc8uP90Pz9k1 HhEnu7gt4bqN7XuyTVPZiyOEej1sDfWL4hu5y2mWwhEw/j0kn1YCwujEfMYx7U/iPJ/x BnG/vE44qWEzSEUNtLbtazphYZzh4wLaoHs6SQx676UFWMLxLqUUMPZcU1zVgy++lo+k qbTsSitE8ZAuZt4lPZgqDMs6h2cKMPclHE6yAT0ZFDm77gkfTaj51WBUBWT2ajvxCPfQ QkTg== X-Gm-Message-State: APzg51A1uSw/viaV7SCV8nj1/cXRfFMHR9ZdNCkUygYgmoaIbVStYVai 38jWjb67kYjYFASpmbPEBj8= X-Google-Smtp-Source: ANB0VdbbK1td76AZu+LPUzYWB0DxJtoesky4fRgKWw06+zohPICrADYgVF+WtlBgQY/TZorvaJ1aBA== X-Received: by 2002:aca:a6d4:: with SMTP id t81-v6mr29430658oij.113.1536157038978; Wed, 05 Sep 2018 07:17:18 -0700 (PDT) To: kvm , qemu-devel@nongnu.org From: Quan Xu Message-ID: Date: Wed, 5 Sep 2018 22:17:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] Subject: [RFC PATCH v2] migration: calculate remaining pages accurately during the bulk stage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr. David Alan Gilbert" , quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8"; format="flowed" From 7de4cc7c944bfccde0ef10992a7ec882fdcf0508 Mon Sep 17 00:00:00 2001 From: Quan Xu Date: Wed, 5 Sep 2018 22:06:58 +0800 Subject: [RFC PATCH v2] migration: calculate remaining pages accurately=20 during the bulk stage Since the bulk stage assumes in (migration_bitmap_find_dirty) that every page is dirty, initialize the number of dirty pages at the beggining of the iteration and then decrease it for each processed page. Signed-off-by: Quan Xu --- migration/ram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 79c8942..1a11436 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -290,6 +290,8 @@ struct RAMState { uint32_t last_version; /* We are in the first round */ bool ram_bulk_stage; + /* Remaining bytes in the first round */ + uint64_t ram_bulk_bytes; /* How many times we have dirty too many pages */ int dirty_rate_high_cnt; /* these variables are used for bitmap sync */ @@ -1540,6 +1542,7 @@ unsigned long migration_bitmap_find_dirty(RAMState=20 *rs, RAMBlock *rb, if (rs->ram_bulk_stage && start > 0) { next =3D start + 1; + rs->ram_bulk_bytes -=3D TARGET_PAGE_SIZE; } else { next =3D find_next_bit(bitmap, size, start); } @@ -2001,6 +2004,7 @@ static bool find_dirty_block(RAMState *rs,=20 PageSearchStatus *pss, bool *again) /* Flag that we've looped */ pss->complete_round =3D true; rs->ram_bulk_stage =3D false; + rs->ram_bulk_bytes =3D 0; if (migrate_use_xbzrle()) { /* If xbzrle is on, stop using the data compression at=20 this * point. In theory, xbzrle can do better than=20 compression. @@ -2513,6 +2517,7 @@ static void ram_state_reset(RAMState *rs) rs->last_page =3D 0; rs->last_version =3D ram_list.version; rs->ram_bulk_stage =3D true; + rs->ram_bulk_bytes =3D ram_bytes_total(); } #define MAX_WAIT 50 /* ms, half buffered_file limit */ @@ -3308,7 +3313,7 @@ static void ram_save_pending(QEMUFile *f, void=20 *opaque, uint64_t max_size, /* We can do postcopy, and all the data is postcopiable */ *res_compatible +=3D remaining_size; } else { - *res_precopy_only +=3D remaining_size; + *res_precopy_only +=3D remaining_size + rs->ram_bulk_bytes; } } -- 1.8.3.1