From nobody Tue Feb 10 11:24:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635804621; cv=none; d=zohomail.com; s=zohoarc; b=WlwJ+ES70NJ2zFIcg0WOllLA6itDCvrbqT+1pdpKmdVtjfM0YlCX8HGyBuxtTmVxAsxLTyDvlGCdchPQxMib4UUQ/A7Q9uonYaswLZDi6YY50Ezn7vO5Pf+vEcsHUReXs2xfW8UQzIy9q+9pll0Rkrxv3B7dp4UPNw/zaeFdYW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635804621; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UH6qFcOvOngPka/Fe9lzsDNdrqD8p0gmRL7v9NgF7Ts=; b=E/zw5VfXXYNQmEJe7ZePCJjQwp2MO6vo4eNyCla9jlZmJxAv67NGN4UTWHYhAoDfyoBZ7seH3raK3lrSyokfjOiW+sEwcHRHg1gFkVQLprEuyaC67jTMrlgNod6wsMcmaqcKxmxYRkL+cYqt/m2g2Y6mIxsnTelVCEfuqm4UqCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1635804621246707.2360908850459; Mon, 1 Nov 2021 15:10:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.219440.380327 (Exim 4.92) (envelope-from ) id 1mhfUx-0003RM-Ik; Mon, 01 Nov 2021 22:09:47 +0000 Received: by outflank-mailman (output) from mailman id 219440.380327; Mon, 01 Nov 2021 22:09:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mhfUx-0003R9-Dv; Mon, 01 Nov 2021 22:09:47 +0000 Received: by outflank-mailman (input) for mailman id 219440; Mon, 01 Nov 2021 22:09:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mhfUv-0007pr-Ny for xen-devel@lists.xenproject.org; Mon, 01 Nov 2021 22:09:45 +0000 Received: from us-smtp-delivery-124.mimecast.com (unknown [170.10.133.124]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 5fdced30-3b60-11ec-854e-12813bfff9fa; Mon, 01 Nov 2021 22:09:26 +0000 (UTC) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210--p4wCkVRNFiI7wBM2qGXGQ-1; Mon, 01 Nov 2021 18:09:23 -0400 Received: by mail-wr1-f72.google.com with SMTP id p17-20020adff211000000b0017b902a7701so3974679wro.19 for ; Mon, 01 Nov 2021 15:09:23 -0700 (PDT) Received: from localhost (static-233-86-86-188.ipcom.comunitel.net. [188.86.86.233]) by smtp.gmail.com with ESMTPSA id n15sm637153wmq.38.2021.11.01.15.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 15:09:21 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5fdced30-3b60-11ec-854e-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635804566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UH6qFcOvOngPka/Fe9lzsDNdrqD8p0gmRL7v9NgF7Ts=; b=U+vt9jf4jS/HiIfTMU0r9zWFdythg50gtGQSjozlCZzWEI6wtMtj7+Xt1m5IZfj+g8Luob XU2CUH3ouytVFrW0wLPjGujJNqcbhDTMOJET9qZgANrChSQTOOJC0yNJdgz7oKa7Reg0ji wpsM2LEAOgt2NDcrr4HIXsft3rjRNfU= X-MC-Unique: -p4wCkVRNFiI7wBM2qGXGQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UH6qFcOvOngPka/Fe9lzsDNdrqD8p0gmRL7v9NgF7Ts=; b=okvxTuVmYhnI4rLf8HhIpYHBGE3nvBm4QgBga8AAiHghp0KQSwMU9mk1rApgddm9Tf 9Bc8qWEAE/4cpH+342uNiWcuSyLfvCVPGnF63b3AOwVZvdjoRmHxGwGLw61gBzb9jxXC WGXsl4rWeRTmz7pIXQbKrBHHn1DE18pG7nq04UlzwbCdOC47l7WV+Bvorgo294aproOf edydQDvqjLLXNNT8K8GqAywI3scupP0mpUglqbJnXZAuEEytJhzccYkyS1P+A20WoB3T is9tk7iVjqwhGE6vciQ9XNxUbAWZuAHcIICLVK7rkysftiAM7cC9j9tSpv3w4ZJ+jkhC kUGg== X-Gm-Message-State: AOAM533q5prTnaEGRhDnSop/M2ppJqHXBoXe0y6uSOZpkRtWgFc+vDgy 4fe5gJfXygBkxm8bOH65WBPBS6Q6OzW+R22sNgxJA+RXFaO/h1wuPXEkEvNfxVpBbOLetOEo6Y0 hCWwz4KTQAJNQ1zF52KXjX568KYg= X-Received: by 2002:adf:d20e:: with SMTP id j14mr33297701wrh.220.1635804562476; Mon, 01 Nov 2021 15:09:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkffbvXrtYSeZN/zNmfpHm8cIwzDDYcEpAf91jdU0NQr69iLSppRQMuLbVQCsCLOwkm5qiNw== X-Received: by 2002:adf:d20e:: with SMTP id j14mr33297679wrh.220.1635804562331; Mon, 01 Nov 2021 15:09:22 -0700 (PDT) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Markus Armbruster , David Hildenbrand , Eduardo Habkost , xen-devel@lists.xenproject.org, Richard Henderson , Stefano Stabellini , Marcel Apfelbaum , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paul Durrant , Paolo Bonzini , "Dr. David Alan Gilbert" , Juan Quintela , "Michael S. Tsirkin" , Anthony Perard , =?UTF-8?q?Hyman=20Huang=28=C3=A9=C2=BB=E2=80=9E=C3=A5=E2=80=B9?= =?UTF-8?q?=E2=80=A1=29?= Subject: [PULL 06/20] migration/dirtyrate: move init step of calculation to main thread Date: Mon, 1 Nov 2021 23:08:58 +0100 Message-Id: <20211101220912.10039-7-quintela@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101220912.10039-1-quintela@redhat.com> References: <20211101220912.10039-1-quintela@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635804623000100001 From: Hyman Huang(=C3=A9=C2=BB=E2=80=9E=C3=A5=E2=80=B9=E2=80=A1) 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(=C3=A9=C2=BB=E2=80=9E=C3=A5=E2=80=B9=E2=80=A1) <= huangy81@chinatelecom.cn> Message-Id: <109f8077518ed2f13068e3bfb10e625e964780f1.1624040308.git.huangy= 81@chinatelecom.cn> Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/dirtyrate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index a9bdd60034..b8f61cc650 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 2.33.1