qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dongli Zhang <dongli.zhang@oracle.com>
To: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Zhao Liu <zhao1.liu@intel.com>, Zide Chen <zide.chen@intel.com>,
	Xiaoyao Li <xiaoyao.li@intel.com>,
	Mingwei Zhang <mizhang@google.com>,
	Sean Christopherson <seanjc@google.com>,
	Das Sandipan <Sandipan.Das@amd.com>,
	Shukla Manali <Manali.Shukla@amd.com>,
	Dapeng Mi <dapeng1.mi@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 2/3] target/i386: Call KVM_CAP_PMU_CAPABILITY iotcl to enable/disable PMU
Date: Tue, 25 Mar 2025 23:46:50 -0700	[thread overview]
Message-ID: <3a01b0d8-8f0b-4068-8176-37f61295f87f@oracle.com> (raw)
In-Reply-To: <20250324123712.34096-3-dapeng1.mi@linux.intel.com>

Hi Dapeng,

PATCH 1-4 from the below patchset are already reviewed. (PATCH 5-10 are for PMU
registers reset).

https://lore.kernel.org/all/20250302220112.17653-1-dongli.zhang@oracle.com/

They require only trivial modification. i.e.:

https://github.com/finallyjustice/patchset/tree/master/qemu-amd-pmu-mid/v03

Therefore, since PATCH 5-10 are for another topic, any chance if I re-send 1-4
as a prerequisite for the patch to explicitly call KVM_CAP_PMU_CAPABILITY?

In addition, I have a silly question. Can mediated vPMU coexist with legacy
perf-based vPMU, that is, something like tdp and tdp_mmu? Or the legacy
perf-based vPMU is going to be purged from the most recent kernel?

If they can coexist, how about add property to QEMU control between
legacy/modern? i.e. by default use legacy and change to modern as default in the
future once the feature is stable.

Thank you very much!

Dongli Zhang

On 3/24/25 5:37 AM, Dapeng Mi wrote:
> After introducing mediated vPMU, mediated vPMU must be enabled by
> explicitly calling KVM_CAP_PMU_CAPABILITY to enable. Thus call
> KVM_CAP_PMU_CAPABILITY to enable/disable PMU base on user configuration.
> 
> Suggested-by: Zhao Liu <zhao1.liu@intel.com>
> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> ---
>  target/i386/kvm/kvm.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index f41e190fb8..d3e6984844 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -2051,8 +2051,25 @@ full:
>      abort();
>  }
>  
> +static bool pmu_cap_set = false;
>  int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp)
>  {
> +    KVMState *s = kvm_state;
> +    X86CPU *x86_cpu = X86_CPU(cpu);
> +
> +    if (!pmu_cap_set && kvm_check_extension(s, KVM_CAP_PMU_CAPABILITY)) {
> +        int r = kvm_vm_enable_cap(s, KVM_CAP_PMU_CAPABILITY, 0,
> +                                  KVM_PMU_CAP_DISABLE & !x86_cpu->enable_pmu);
> +        if (r < 0) {
> +            error_report("kvm: Failed to %s pmu cap: %s",
> +                         x86_cpu->enable_pmu ? "enable" : "disable",
> +                         strerror(-r));
> +            return r;
> +        }
> +
> +        pmu_cap_set = true;
> +    }
> +
>      return 0;
>  }
>  



  reply	other threads:[~2025-03-26  6:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 12:37 [PATCH 0/3] Enable x86 mediated vPMU Dapeng Mi
2025-03-24 12:37 ` [PATCH 1/3] kvm: Introduce kvm_arch_pre_create_vcpu() Dapeng Mi
2025-03-24 12:37 ` [PATCH 2/3] target/i386: Call KVM_CAP_PMU_CAPABILITY iotcl to enable/disable PMU Dapeng Mi
2025-03-26  6:46   ` Dongli Zhang [this message]
2025-03-27  0:44     ` Mi, Dapeng
2025-03-27  2:15       ` Mingwei Zhang
2025-03-27  3:47         ` Mi, Dapeng
2025-03-24 12:37 ` [PATCH 3/3] target/i386: Support VMX_VM_EXIT_SAVE_IA32_PERF_GLOBAL_CTRL Dapeng Mi
2025-04-27  8:54   ` Zhao Liu
2025-04-27  9:42     ` Mi, Dapeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a01b0d8-8f0b-4068-8176-37f61295f87f@oracle.com \
    --to=dongli.zhang@oracle.com \
    --cc=Manali.Shukla@amd.com \
    --cc=Sandipan.Das@amd.com \
    --cc=dapeng1.mi@intel.com \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=mizhang@google.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seanjc@google.com \
    --cc=xiaoyao.li@intel.com \
    --cc=zhao1.liu@intel.com \
    --cc=zide.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).