From nobody Mon Feb 9 15:47:19 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 162498316225816.87917988360357; Tue, 29 Jun 2021 09:12:42 -0700 (PDT) Received: from localhost ([::1]:54554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyGLp-00040h-HI for importer@patchew.org; Tue, 29 Jun 2021 12:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyGBp-00032a-Re for qemu-devel@nongnu.org; Tue, 29 Jun 2021 12:02:21 -0400 Received: from prt-mail.chinatelecom.cn ([42.123.76.223]:60799 helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyGBQ-0002jY-Dy for qemu-devel@nongnu.org; Tue, 29 Jun 2021 12:02:21 -0400 Received: from clientip-125.69.43.101?logid-9af499b632ef4d88aa693d3105be9e2a (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id 1E3A6280094; Wed, 30 Jun 2021 00:01:53 +0800 (CST) Received: from ([172.18.0.48]) by app0024 with ESMTP id 940401b12f584787b7583825811309d7 for qemu-devel@nongnu.org; Wed Jun 30 00:01:56 2021 HMM_SOURCE_IP: 172.18.0.48:60674.1189130900 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 940401b12f584787b7583825811309d7 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 v12 5/6] migration/dirtyrate: move init step of calculation to main thread Date: Wed, 30 Jun 2021 00:01:22 +0800 Message-Id: <494a2b9c51ebc7734ec09f0edb72dcea40ca9dc5.1624982117.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.223; 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=unavailable 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" From: Hyman Huang(=E9=BB=84=E5=8B=87) since main thread may "query dirty rate" at any time, it's better to move init step into main thead so that synchronization overhead between "main" and "get_dirtyrate" can be reduced. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) Message-Id: <109f8077518ed2f13068e3bfb10e625e964780f1.1624040308.git.huangy= 81@chinatelecom.cn> Reviewed-by: Peter Xu --- migration/dirtyrate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index a9bdd60..b8f61cc 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -380,7 +380,6 @@ void *get_dirtyrate_thread(void *arg) { struct DirtyRateConfig config =3D *(struct DirtyRateConfig *)arg; int ret; - int64_t start_time; rcu_register_thread(); =20 ret =3D dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_UNSTA= RTED, @@ -390,9 +389,6 @@ void *get_dirtyrate_thread(void *arg) return NULL; } =20 - start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000; - init_dirtyrate_stat(start_time, config); - calculate_dirtyrate(config); =20 ret =3D dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_MEASU= RING, @@ -411,6 +407,7 @@ void qmp_calc_dirty_rate(int64_t calc_time, bool has_sa= mple_pages, static struct DirtyRateConfig config; QemuThread thread; int ret; + int64_t start_time; =20 /* * If the dirty rate is already being measured, don't attempt to start. @@ -451,6 +448,10 @@ void qmp_calc_dirty_rate(int64_t calc_time, bool has_s= ample_pages, config.sample_period_seconds =3D calc_time; config.sample_pages_per_gigabytes =3D sample_pages; config.mode =3D DIRTY_RATE_MEASURE_MODE_PAGE_SAMPLING; + + start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000; + init_dirtyrate_stat(start_time, config); + qemu_thread_create(&thread, "get_dirtyrate", get_dirtyrate_thread, (void *)&config, QEMU_THREAD_DETACHED); } --=20 1.8.3.1