From nobody Tue Nov 4 15:15:43 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530132474611196.0095743573969; Wed, 27 Jun 2018 13:47:54 -0700 (PDT) Received: from localhost ([::1]:33122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHLs-0007Qd-OJ for importer@patchew.org; Wed, 27 Jun 2018 16:47:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHGp-0003vc-IE for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:42:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYHGo-0006Az-IO for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:42:31 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:41162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYHGo-0006A2-Bb for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:42:30 -0400 Received: by mail-pl0-x244.google.com with SMTP id w8-v6so1594783ply.8 for ; Wed, 27 Jun 2018 13:42:30 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id c67-v6sm9690428pfj.173.2018.06.27.13.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 13:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BlmXYOMD7aS9b5gmx01wGSp+AEPIzdhdvfz8COXFZ6I=; b=HMDFTf1+hoU/JboktfQ+Ub5PDmGu+X1C2ifTCmjCErvWIC4E+0OpW8xaY8H0CRSPM2 ze9t3lh48u1z8KZasfuW6LUCRwapHEv4rM3FyPuEpKYirkMZj87/EN4Z4SNNoTsIsDA7 pMOy9Pq4ZyrxQ0fvhA2PThAFLcxN3+LCdzFD7oe78+FQ0ufBnFo8ucoayyRM0RIORhL7 Su43qDDTOpk+lM1r5qDt7MprVh0CtEmFK3nZBizT20FhIcjBqIoKPt/wsaSAxzJxHJZA u70en4sUw2e5ntNCXfVoiWW7KYjBlyfszJqyZTZjbbrztSVerQmnioCvw1QnXEMGYKVT OKmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BlmXYOMD7aS9b5gmx01wGSp+AEPIzdhdvfz8COXFZ6I=; b=PeijHQVzmrVjF/aJHsVk28UnCJF4v5cHFS4dBtfJw+mQXta6yEydzgTa3iEhCgtqQS oQqKDzHkUjMXTsG069lVBp/EvybgsHgK2VcZWOdMtUxIhh4sQ3sB7QFSFolbOl2DCIhl ssiwi9qaNjhWXW/3J8SQje2yTi7fxkLu8WI9KmfFGjUKga4RxRn5phoUdwH/3cqa62sc A6b74CVbRWM032/2P7EQ6WChwrl1SlJ1k8Bz9LznaNCarZzN/gVVkCQHWlKSynzidGVU vMc9C0olozlxGqPlgeXEgsMxRDwgTc11ZB64PXPVRYzNNrUoXF2KNtMRrdeAjxOzDSsi 2RTA== X-Gm-Message-State: APt69E2FzH3gOwIcMBGneShDAtlVmPLE5bsbG0iJbENq6B6nyfZMfNEV 3qb1jjSK9cMEP9X498ukhgiU6A== X-Google-Smtp-Source: ADUXVKJJCsMfl6mlout0KSUc/L8nqpH6kUAjD6h5OmK4F7+VWVHFPThNkhqD3GrY7LN3EaABZ6k+gg== X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr7527052plo.337.1530132149095; Wed, 27 Jun 2018 13:42:29 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Jason Wang , Eric Blake , Markus Armbruster Date: Thu, 28 Jun 2018 04:41:24 +0800 Message-Id: <20180627204136.4177-9-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180627204136.4177-1-zhangckid@gmail.com> References: <20180627204136.4177-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH V9 08/20] ram/COLO: Record the dirty pages that SVM received 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: zhanghailiang , Li Zhijian , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We record the address of the dirty pages that received, it will help flushing pages that cached into SVM. Here, it is a trick, we record dirty pages by re-using migration dirty bitmap. In the later patch, we will start the dirty log for SVM, just like migration, in this way, we can record both the dirty pages caused by PVM and SVM, we only flush those dirty pages from RAM cache while do checkpoint. Signed-off-by: zhanghailiang Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 30cc83996f..ecc5f46068 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2869,6 +2869,15 @@ static inline void *colo_cache_from_block_offset(RAM= Block *block, __func__, block->idstr); return NULL; } + + /* + * During colo checkpoint, we need bitmap of these migrated pages. + * It help us to decide which pages in ram cache should be flushed + * into VM's RAM later. + */ + if (!test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) { + ram_state->migration_dirty_pages++; + } return block->colo_cache + offset; } =20 @@ -3099,6 +3108,24 @@ int colo_init_ram_cache(void) memcpy(block->colo_cache, block->host, block->used_length); } rcu_read_unlock(); + /* + * Record the dirty pages that sent by PVM, we use this dirty bitmap to= gether + * with to decide which page in cache should be flushed into SVM's RAM.= Here + * we use the same name 'ram_bitmap' as for migration. + */ + if (ram_bytes_total()) { + RAMBlock *block; + + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + unsigned long pages =3D block->max_length >> TARGET_PAGE_BITS; + + block->bmap =3D bitmap_new(pages); + bitmap_set(block->bmap, 0, pages); + } + } + ram_state =3D g_new0(RAMState, 1); + ram_state->migration_dirty_pages =3D 0; + return 0; =20 out_locked: @@ -3118,6 +3145,10 @@ void colo_release_ram_cache(void) { RAMBlock *block; =20 + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + g_free(block->bmap); + block->bmap =3D NULL; + } rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { if (block->colo_cache) { @@ -3126,6 +3157,8 @@ void colo_release_ram_cache(void) } } rcu_read_unlock(); + g_free(ram_state); + ram_state =3D NULL; } =20 /** --=20 2.17.GIT