From nobody Sat Nov 23 21:17:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.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=smartx.com ARC-Seal: i=1; a=rsa-sha256; t=1731128475; cv=none; d=zohomail.com; s=zohoarc; b=j6yBGfIT/SUXcWTP0iVIoSBVqWSrE4azF0Ad5dld7WqVZqcrdQ90Vghn/xHKUg3d1N4JvZSYr0jQkx+MoMDLTPLDjthZy54H3prUpgzmv2if+/5nAG8ORDBHOd7FovvsBSnzWnQQFxUUhI/0QyPTklEO3LigGCGEuwNe/ErhbEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731128475; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9gZ+IPpDpfPOMn4j4HmQOIMp3Etb7MIoneItHhCKeWk=; b=AWpWoXy9YYk++5QCfYYnbnoKQ0HjfNrrY9YMvODjndSoZbO9HIhNddwr6rbrfK12EirD4SDmNWgYyGTBxlqk2HaHLSZEU9bUGxCH7U6AeCJO01+ka6tSX8EQjAMmmMOS6FuS8EK3nsVcSoE4DsSEQSPuAiuQkiRVaKvh0uEbpOU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731128475917168.59524141699694; Fri, 8 Nov 2024 21:01:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9dZn-0006O8-5l; Fri, 08 Nov 2024 23:59:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9dZm-0006Ny-Hb for qemu-devel@nongnu.org; Fri, 08 Nov 2024 23:59:58 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9dZk-0000ff-Um for qemu-devel@nongnu.org; Fri, 08 Nov 2024 23:59:58 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-723f37dd76cso3030168b3a.0 for ; Fri, 08 Nov 2024 20:59:56 -0800 (PST) Received: from localhost.localdomain ([118.114.63.54]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724078a9ac8sm4718365b3a.79.2024.11.08.20.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 20:59:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1731128395; x=1731733195; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9gZ+IPpDpfPOMn4j4HmQOIMp3Etb7MIoneItHhCKeWk=; b=Vupv9Iis3qaZo7dkpZdQnmvS5IbskqA3l8d4q42EayJj3aCmtlpbzXV9B3/AGRQSIy 5d/KQAdXc/8UoEorkyBWfQaBljM63vbgDZNKsXaWP1O17Xy4zhJroKA7msXnRzn6/Cpq 8r67I/Ivk61N1d6A+Nmodmdyr0hAgSKI+r/o2WlpfCCc3HbP+DHLCs1ZUCg/dMz+7ewx SPhhICLEX4wfi7TmSCICloQo+5x3XbSQW3Gwir7PVFENEevlbpR/kufJAKvVArs1vDuG u5sfDS6bEYwvk3iqlh31Nwd/t5q5L5AU5DtQ4GMP0//mxHgoPUJf/8CyjzWnGr1BqSti KSbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731128395; x=1731733195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9gZ+IPpDpfPOMn4j4HmQOIMp3Etb7MIoneItHhCKeWk=; b=Q4i+RqpTUnF0PltIbR4JHs19M8wiIte0UaVf3DlBaW3qOASnJRS/RYY5WV0LkrAyQQ aBNKix+C5PHqv1Xvd9ONAnRCXckcglCa8LLXpyMfS2HMcbQD0AYmsxlFHuTvLqYy043r 6liXuktLmoIBYp601wbaxShVkTY+Axth0bkplKexTNRTqu74wPxaB1QVXGZV3T8N7YRM BZ5V61/MGVvnK7zpGDyfiVRFomgsG3YPeoMTIOHV9GXKUssLevdYLY0kW3zftR5j8tfF 9U6Q016q50ded6lDT9ZAYAOrAWFkL7GS7WOYio5SM+SNegANzyikbX7d3O5nTr2fG/EX c8EQ== X-Gm-Message-State: AOJu0YylW4+xHBHE11cuv/d9anu1Tmv/tmGOQdUyxOY6QzVIU2tODxZN vBZ62kGjK4kXWN+LfV3hTWXdM6P4wqpHJzVS1/94u2Ku/uHBuDvRYjz686vaUgc8V/A3lheRP7G p6PRTqw== X-Google-Smtp-Source: AGHT+IEYRMb8PSniLyEY2Zm2c9vYRGR0BcNWSXnvN8o37e612lhZkpx5cn+khrUzc8vMT0QM4DoneQ== X-Received: by 2002:a05:6a21:8cca:b0:1db:df7b:471a with SMTP id adf61e73a8af0-1dc22b9162amr7666446637.43.1731128394606; Fri, 08 Nov 2024 20:59:54 -0800 (PST) From: Hyman Huang To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Wei Wang , David Hildenbrand , "Michael S . Tsirkin" , yong.huang@smartx.com Subject: [PATCH v1 2/2] migration: Do not perform RAMBlock dirty sync during the first iteration Date: Sat, 9 Nov 2024 12:59:42 +0800 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=yong.huang@smartx.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1731128477027116600 Content-Type: text/plain; charset="utf-8" The first iteration's RAMBlock dirty sync can be omitted because QEMU always initializes the RAMBlock's bmap to all 1s by default. Signed-off-by: Hyman Huang --- migration/cpu-throttle.c | 2 +- migration/ram.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/migration/cpu-throttle.c b/migration/cpu-throttle.c index 5179019e33..674dc2004e 100644 --- a/migration/cpu-throttle.c +++ b/migration/cpu-throttle.c @@ -141,7 +141,7 @@ void cpu_throttle_dirty_sync_timer_tick(void *opaque) * effect on guest performance, therefore omit it to avoid * paying extra for the sync penalty. */ - if (sync_cnt <=3D 1) { + if (!sync_cnt) { goto end; } =20 diff --git a/migration/ram.c b/migration/ram.c index 05ff9eb328..571dba10b7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2718,7 +2718,7 @@ static void ram_list_init_bitmaps(void) { MigrationState *ms =3D migrate_get_current(); RAMBlock *block; - unsigned long pages; + unsigned long pages, clear_bmap_pages; uint8_t shift; =20 /* Skip setting bitmap if there is no RAM */ @@ -2736,6 +2736,7 @@ static void ram_list_init_bitmaps(void) =20 RAMBLOCK_FOREACH_NOT_IGNORED(block) { pages =3D block->max_length >> TARGET_PAGE_BITS; + clear_bmap_pages =3D clear_bmap_size(pages, shift); /* * The initial dirty bitmap for migration must be set with all * ones to make sure we'll migrate every guest RAM page to @@ -2751,7 +2752,12 @@ static void ram_list_init_bitmaps(void) block->file_bmap =3D bitmap_new(pages); } block->clear_bmap_shift =3D shift; - block->clear_bmap =3D bitmap_new(clear_bmap_size(pages, shift)= ); + block->clear_bmap =3D bitmap_new(clear_bmap_pages); + /* + * Set clear_bmap to 1 unconditionally, as we always set bmap + * to all 1s by default. + */ + bitmap_set(block->clear_bmap, 0, clear_bmap_pages); } } } @@ -2783,7 +2789,6 @@ static bool ram_init_bitmaps(RAMState *rs, Error **er= rp) if (!ret) { goto out_unlock; } - migration_bitmap_sync_precopy(false); } } out_unlock: --=20 2.39.1