From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 4/4] perf/x86: KVM: Have perf define a dedicated struct for getting guest PEBS data
Date: Thu, 23 Apr 2026 23:31:45 +0000 [thread overview]
Message-ID: <20260423233145.DDC5BC2BCAF@smtp.kernel.org> (raw)
In-Reply-To: <20260423150340.463896-5-seanjc@google.com>
Sashiko AI review found 1 potential issue(s):
- [Medium] Unconditional external function call to intel_pmu_get_cross_mapped_mask() introduced in the VMX hot path.
--
commit bf596eb4f1ae159ccdd3b9e0517c0eaa4c80ce4a
Author: Sean Christopherson <seanjc@google.com>
perf/x86: KVM: Have perf define a dedicated struct for getting guest PEBS data
This commit introduces a dedicated struct (x86_guest_pebs) for passing guest
PEBS data from KVM to perf. It replaces the previous method of passing an
opaque pointer to kvm_pmu, allowing perf to define its own data requirements
independently of KVM-internal state.
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index a29896a9ef1456..e6c1c64a8c949d 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7313,12 +7313,15 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
> if (kvm_vcpu_has_mediated_pmu(&vmx->vcpu))
> return;
>
> - pmu->host_cross_mapped_mask = 0;
> - if (pmu->pebs_enable & pmu->global_ctrl)
> - intel_pmu_cross_mapped_check(pmu);
> + struct x86_guest_pebs guest_pebs = {
> + .enable = pmu->pebs_enable,
> + .ds_area = pmu->ds_area,
> + .data_cfg = pmu->pebs_data_cfg,
> + .cross_mapped_mask = intel_pmu_get_cross_mapped_mask(pmu),
> + };
Does this introduce an unnecessary function call overhead on the VMX hot path?
Prior to this patch, the external function intel_pmu_cross_mapped_check()
was conditionally called only when PEBS was enabled, which avoided an
external function call in the vast majority of cases.
Because intel_pmu_get_cross_mapped_mask() is in a different compilation
unit (pmu_intel.c), calling it unconditionally here results in a function
call on every VM-entry.
Would it be better to restore the inline condition check, perhaps using a
ternary operator when initializing cross_mapped_mask?
>
> /* Note, nr_msrs may be garbage if perf_guest_get_msrs() returns NULL. */
> - msrs = perf_guest_get_msrs(&nr_msrs, (void *)pmu);
> + msrs = perf_guest_get_msrs(&nr_msrs, &guest_pebs);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260423150340.463896-1-seanjc@google.com?part=4
next prev parent reply other threads:[~2026-04-23 23:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 15:03 [PATCH v2 0/4] perf/x86: Don't write PEBS_ENABLED on KVM transitions Sean Christopherson
2026-04-23 15:03 ` [PATCH v2 1/4] perf/x86/intel: Don't write PEBS_ENABLED on host<=>guest xfers if CPU has isolation Sean Christopherson
2026-04-23 16:22 ` Peter Zijlstra
2026-04-23 17:59 ` Jim Mattson
2026-04-23 15:03 ` [PATCH v2 2/4] perf/x86/intel: Don't context switch DS_AREA (and PEBS config) if PEBS is unused Sean Christopherson
2026-04-23 15:03 ` [PATCH v2 3/4] perf/x86/intel: Make @data a mandatory param for intel_guest_get_msrs() Sean Christopherson
2026-04-23 15:03 ` [PATCH v2 4/4] perf/x86: KVM: Have perf define a dedicated struct for getting guest PEBS data Sean Christopherson
2026-04-23 18:14 ` Jim Mattson
2026-04-23 23:31 ` sashiko-bot [this message]
2026-04-23 15:33 ` [PATCH v2 0/4] perf/x86: Don't write PEBS_ENABLED on KVM transitions Jim Mattson
2026-04-23 16:16 ` Peter Zijlstra
2026-04-24 12:17 ` Mi, Dapeng
2026-04-24 12:23 ` Peter Zijlstra
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=20260423233145.DDC5BC2BCAF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=seanjc@google.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