From nobody Tue Feb 10 20:30:06 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 ARC-Seal: i=1; a=rsa-sha256; t=1623028774; cv=none; d=zohomail.com; s=zohoarc; b=P2PfAzK4ejZldnqk7L6kF6j4GzdPyTBjH/mjwzmLq2ft0ONOyiHe+nC5bkZGW3tEDc4e0UBGWvPaQ8OklIAYVTdGUiv1Ydj4IMrgk+wSJQDmbAlDJpDPAuhJFn18lf+yL8IRAfS527Xa4KPgANT85cwIptRR5d0xCjdr/jb55lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623028774; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kpn+7/w1jq/joSEbdWBoa9JKiOLx7bNNf6ckE3CnT2M=; b=fxlOAQvUM9Dt3zE7EhN31ip7/qE8adLcn6OKLlia/XrgrWx/OUBjUhHJq7IT/sZseQuGmXyprcyc0ngIj//HOfIP45xU98cdnTHJ4S7wC5yhcb1aNNYxNw2vx3z69Z5LZpmpjETrLXNt1/rnQlz9FhuyZulVPnBz1jQ46jBnSGc= ARC-Authentication-Results: i=1; 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 1623028773399152.08215374267718; Sun, 6 Jun 2021 18:19:33 -0700 (PDT) Received: from localhost ([::1]:33944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lq3vP-0003Dx-RY for importer@patchew.org; Sun, 06 Jun 2021 21:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lq3qa-0005Y2-HY for qemu-devel@nongnu.org; Sun, 06 Jun 2021 21:14:32 -0400 Received: from [42.123.76.228] (port=47794 helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lq3pZ-0003yQ-W5 for qemu-devel@nongnu.org; Sun, 06 Jun 2021 21:14:08 -0400 Received: from clientip-182.138.181.182?logid-563a6af5169d4a62a342ee8f158fb98f (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id CD15D280132; Mon, 7 Jun 2021 09:12:20 +0800 (CST) Received: from ([172.18.0.48]) by app0024 with ESMTP id 563a6af5169d4a62a342ee8f158fb98f for qemu-devel@nongnu.org; Mon Jun 7 09:12:20 2021 HMM_SOURCE_IP: 172.18.0.48:60748.791983158 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 563a6af5169d4a62a342ee8f158fb98f X-filter-score: filter<0> 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 v3 3/7] KVM: introduce dirty_pages and kvm_dirty_ring_enabled Date: Mon, 7 Jun 2021 09:12:14 +0800 Message-Id: <5fd7f4b444d14447649982ed44c5ddc5ebde635c.1623027729.git.huangy81@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 42.123.76.228 (deferred) 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.228; envelope-from=huangy81@chinatelecom.cn; helo=chinatelecom.cn X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=no 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 , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Hyman Huang(=E9=BB=84=E5=8B=87) dirty_pages is used to calculate dirtyrate via dirty ring, when enabled, kvm-reaper will increase the dirty pages after gfns being dirtied. kvm_dirty_ring_enabled shows if kvm-reaper is working. dirtyrate thread could use it to check if measurement can base on dirty ring feature. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- accel/kvm/kvm-all.c | 7 +++++++ include/hw/core/cpu.h | 1 + include/sysemu/kvm.h | 1 + 3 files changed, 9 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c7ec538850..bc012f0bee 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -469,6 +469,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) cpu->kvm_fd =3D ret; cpu->kvm_state =3D s; cpu->vcpu_dirty =3D true; + cpu->dirty_pages =3D 0; =20 mmap_size =3D kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0); if (mmap_size < 0) { @@ -743,6 +744,7 @@ static uint32_t kvm_dirty_ring_reap_one(KVMState *s, CP= UState *cpu) count++; } cpu->kvm_fetch_index =3D fetch; + cpu->dirty_pages +=3D count; =20 return count; } @@ -2293,6 +2295,11 @@ bool kvm_vcpu_id_is_valid(int vcpu_id) return vcpu_id >=3D 0 && vcpu_id < kvm_max_vcpu_id(s); } =20 +bool kvm_dirty_ring_enabled(void) +{ + return kvm_state->kvm_dirty_ring_size ? true : false; +} + static int kvm_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 4e0ea68efc..80fcb1d563 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -374,6 +374,7 @@ struct CPUState { struct kvm_run *kvm_run; struct kvm_dirty_gfn *kvm_dirty_gfns; uint32_t kvm_fetch_index; + uint64_t dirty_pages; =20 /* Used for events with 'vcpu' and *without* the 'disabled' properties= */ DECLARE_BITMAP(trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index a1ab1ee12d..7b22aeb6ae 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -547,4 +547,5 @@ bool kvm_cpu_check_are_resettable(void); =20 bool kvm_arch_cpu_check_are_resettable(void); =20 +bool kvm_dirty_ring_enabled(void); #endif --=20 2.18.2