From nobody Thu May 16 20:28:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1559608199; cv=none; d=zoho.com; s=zohoarc; b=e1oTXAg2UCEdxr60SILbv5wVVLjbtK3B5Me128niFjhI7/a89JtF/BOqrDZ7DbxNXLNBRpTSSIpq1hY7UMzreSXtybkmbcP5BBKDdkTZUwGBeJJnbPLU0jg2kHxUlGYze7t6z1KOKxFkzfEL2GG+KGGtwZo38Kt2VIZ1Igs4RxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559608199; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=ncyiAeRAqHGLEH6B/SGY2qhY/ZHZ7Pgk173RDPGrcqM=; b=RPw5hQX9BQ7ITTpXR9Ri/thc2me5G9ziOuthiHXgaLz2xMmy6jrqlZeEnu01070a+y/yjN+Kd4OKngcREWVWArOOFfOQycS2VFJ6p/ZWNUyZ6h+9grZhWYkK63czQlIXVMUxOguDXbKNsZsKl430R0vsVOhTjlS6b4ychUrKXsc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559608199186624.1050995412263; Mon, 3 Jun 2019 17:29:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:42884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXxKo-0007Gv-Qb for importer@patchew.org; Mon, 03 Jun 2019 20:29:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXxJv-0006xu-RU for qemu-devel@nongnu.org; Mon, 03 Jun 2019 20:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXxJu-0003hb-OQ for qemu-devel@nongnu.org; Mon, 03 Jun 2019 20:28:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:3584) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXxJs-0003bP-Na for qemu-devel@nongnu.org; Mon, 03 Jun 2019 20:28:54 -0400 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 17:28:41 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga008.fm.intel.com with ESMTP; 03 Jun 2019 17:28:39 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Tue, 4 Jun 2019 08:28:10 +0800 Message-Id: <20190604002810.12869-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 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: 192.55.52.93 Subject: [Qemu-devel] [PATCH v2] migratioin/ram: leave RAMBlock->bmap blank on allocating 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: Wei Yang , dgilbert@redhat.com, peterx@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" During migration, we would sync bitmap from ram_list.dirty_memory to RAMBlock.bmap in cpu_physical_memory_sync_dirty_bitmap(). Since we set RAMBlock.bmap and ram_list.dirty_memory both to all 1, this means at the first round this sync is meaningless and is a duplicated work. Leaving RAMBlock->bmap blank on allocating would have a side effect on migration_dirty_pages, since it is calculated from the result of cpu_physical_memory_sync_dirty_bitmap(). To keep it right, we need to set migration_dirty_pages to 0 in ram_state_init(). Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert --- v2: add a comment explaining why leaving RAMBlock.bmap clear --- migration/ram.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4c60869226..e9a27ea5e6 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3181,12 +3181,7 @@ static int ram_state_init(RAMState **rsp) qemu_mutex_init(&(*rsp)->src_page_req_mutex); QSIMPLEQ_INIT(&(*rsp)->src_page_requests); =20 - /* - * Count the total number of pages used by ram blocks not including any - * gaps due to alignment or unplugs. - */ - (*rsp)->migration_dirty_pages =3D ram_bytes_total() >> TARGET_PAGE_BIT= S; - + (*rsp)->migration_dirty_pages =3D 0; ram_state_reset(*rsp); =20 return 0; @@ -3201,8 +3196,15 @@ static void ram_list_init_bitmaps(void) if (ram_bytes_total()) { RAMBLOCK_FOREACH_NOT_IGNORED(block) { pages =3D block->max_length >> TARGET_PAGE_BITS; + /* + * We leave RAMBlock.bmap clear here and they will be sync from + * ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] in + * migration_bitmap_sync_precopy(). + * + * ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION] is set to all= 1 + * in ram_block_add(). + */ block->bmap =3D bitmap_new(pages); - bitmap_set(block->bmap, 0, pages); if (migrate_postcopy_ram()) { block->unsentmap =3D bitmap_new(pages); bitmap_set(block->unsentmap, 0, pages); --=20 2.19.1