From nobody Tue Feb 10 03:19:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162643383923054.83768432018701; Fri, 16 Jul 2021 04:10:39 -0700 (PDT) Received: from localhost ([::1]:34042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Ljq-0000Ic-1h for importer@patchew.org; Fri, 16 Jul 2021 07:10:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4LiB-0006lt-OV for qemu-devel@nongnu.org; Fri, 16 Jul 2021 07:08:55 -0400 Received: from prt-mail.chinatelecom.cn ([42.123.76.227]:37257 helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4Li9-00041q-88 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 07:08:55 -0400 Received: from clientip-202.80.192.38?logid-1296ba80555d44f48fdbc417a7cadc3f (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id 4A0F0280029; Fri, 16 Jul 2021 19:08:51 +0800 (CST) Received: from ([172.18.0.48]) by app0024 with ESMTP id 90defc48a05944b09c8a3e7b3b390cda for qemu-devel@nongnu.org; Fri Jul 16 19:08:53 2021 HMM_SOURCE_IP: 172.18.0.48:53240.814476691 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 90defc48a05944b09c8a3e7b3b390cda X-filter-score: X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 172.18.0.48 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: qemu-devel@nongnu.org Subject: [PATCH v6 1/2] memory: introduce total_dirty_pages to stat dirty pages Date: Fri, 16 Jul 2021 19:13:46 +0800 Message-Id: <43f4caeb051eb37f77099420cae2718194d40515.1626433753.git.huangy81@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=42.123.76.227; envelope-from=huangy81@chinatelecom.cn; helo=chinatelecom.cn 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, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Juan Quintela , Hyman , "Dr. David Alan Gilbert" , Peter Xu , Chuan Zheng , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626433840633100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) introduce global var total_dirty_pages to stat dirty pages along with memory_global_dirty_log_sync. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- include/exec/ram_addr.h | 9 +++++++++ migration/dirtyrate.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 45c9132..64fb936 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -26,6 +26,8 @@ #include "exec/ramlist.h" #include "exec/ramblock.h" =20 +extern uint64_t total_dirty_pages; + /** * clear_bmap_size: calculate clear bitmap size * @@ -373,6 +375,10 @@ static inline void cpu_physical_memory_set_dirty_lebit= map(unsigned long *bitmap, qatomic_or( &blocks[DIRTY_MEMORY_MIGRATION][idx][offse= t], temp); + if (unlikely( + global_dirty_tracking & GLOBAL_DIRTY_DIRTY_RAT= E)) { + total_dirty_pages +=3D ctpopl(temp); + } } =20 if (tcg_enabled()) { @@ -403,6 +409,9 @@ static inline void cpu_physical_memory_set_dirty_lebitm= ap(unsigned long *bitmap, for (i =3D 0; i < len; i++) { if (bitmap[i] !=3D 0) { c =3D leul_to_cpu(bitmap[i]); + if (unlikely(global_dirty_tracking & GLOBAL_DIRTY_DIRTY_RA= TE)) { + total_dirty_pages +=3D ctpopl(c); + } do { j =3D ctzl(c); c &=3D ~(1ul << j); diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index f92c4b4..17b3d2c 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -28,6 +28,13 @@ #include "sysemu/runstate.h" #include "exec/memory.h" =20 +/* + * total_dirty_pages is procted by BQL and is used + * to stat dirty pages during the period of two + * memory_global_dirty_log_sync + */ +uint64_t total_dirty_pages; + typedef struct DirtyPageRecord { uint64_t start_pages; uint64_t end_pages; --=20 1.8.3.1