From: Peter Zijlstra <peterz@infradead.org>
To: Like Xu <like.xu.linux@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Jim Mattson <jmattson@google.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Like Xu <likexu@tencent.com>
Subject: Re: [PATCH kvm/queue v2 2/3] perf: x86/core: Add interface to query perfmon_event_map[] directly
Date: Wed, 2 Feb 2022 15:43:08 +0100 [thread overview]
Message-ID: <20220202144308.GB20638@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20220117085307.93030-3-likexu@tencent.com>
On Mon, Jan 17, 2022 at 04:53:06PM +0800, Like Xu wrote:
> From: Like Xu <likexu@tencent.com>
>
> Currently, we have [intel|knc|p4|p6]_perfmon_event_map on the Intel
> platforms and amd_[f17h]_perfmon_event_map on the AMD platforms.
>
> Early clumsy KVM code or other potential perf_event users may have
> hard-coded these perfmon_maps (e.g., arch/x86/kvm/svm/pmu.c), so
> it would not make sense to program a common hardware event based
> on the generic "enum perf_hw_id" once the two tables do not match.
>
> Let's provide an interface for callers outside the perf subsystem to get
> the counter config based on the perfmon_event_map currently in use,
> and it also helps to save bytes.
>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Like Xu <likexu@tencent.com>
> ---
> arch/x86/events/core.c | 9 +++++++++
> arch/x86/include/asm/perf_event.h | 2 ++
> 2 files changed, 11 insertions(+)
>
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 38b2c779146f..751048f4cc97 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -693,6 +693,15 @@ void x86_pmu_disable_all(void)
> }
> }
>
> +u64 perf_get_hw_event_config(int perf_hw_id)
> +{
> + if (perf_hw_id < x86_pmu.max_events)
> + return x86_pmu.event_map(perf_hw_id);
> +
> + return 0;
> +}
Where does perf_hw_id come from? Does this need to be
array_index_nospec() ?
> +EXPORT_SYMBOL_GPL(perf_get_hw_event_config);
Urgh... hate on kvm being a module again. We really need something like
EXPORT_SYMBOL_KVM() or something.
> struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
> {
> return static_call(x86_pmu_guest_get_msrs)(nr);
> diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
> index 8fc1b5003713..d1e325517b74 100644
> --- a/arch/x86/include/asm/perf_event.h
> +++ b/arch/x86/include/asm/perf_event.h
> @@ -492,9 +492,11 @@ static inline void perf_check_microcode(void) { }
>
> #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL)
> extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
> +extern u64 perf_get_hw_event_config(int perf_hw_id);
> extern int x86_perf_get_lbr(struct x86_pmu_lbr *lbr);
> #else
> struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
> +u64 perf_get_hw_event_config(int perf_hw_id);
I think Paolo already spotted this one.
> static inline int x86_perf_get_lbr(struct x86_pmu_lbr *lbr)
> {
> return -1;
> --
> 2.33.1
>
next prev parent reply other threads:[~2022-02-02 14:43 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 8:53 [PATCH kvm/queue v2 0/3] KVM: x86/pmu: Fix out-of-date AMD amd_event_mapping[] Like Xu
2022-01-17 8:53 ` [PATCH kvm/queue v2 1/3] KVM: x86/pmu: Replace pmu->available_event_types with a new BITMAP Like Xu
2022-02-01 12:26 ` Paolo Bonzini
2022-01-17 8:53 ` [PATCH kvm/queue v2 2/3] perf: x86/core: Add interface to query perfmon_event_map[] directly Like Xu
2022-02-01 12:27 ` Paolo Bonzini
2022-02-02 14:43 ` Peter Zijlstra [this message]
2022-02-02 22:35 ` Jim Mattson
2022-02-03 17:33 ` David Dunn
2022-02-09 8:10 ` KVM: x86: Reconsider the current approach of vPMU Like Xu
2022-02-09 13:33 ` Peter Zijlstra
2022-02-09 21:00 ` Sean Christopherson
2022-02-10 12:08 ` Like Xu
2022-02-10 17:12 ` Sean Christopherson
2022-02-16 3:33 ` Like Xu
2022-02-16 17:53 ` Jim Mattson
2022-02-09 13:21 ` [PATCH kvm/queue v2 2/3] perf: x86/core: Add interface to query perfmon_event_map[] directly Peter Zijlstra
2022-02-09 15:40 ` Dave Hansen
2022-02-09 18:47 ` Jim Mattson
2022-02-09 18:57 ` Dave Hansen
2022-02-09 19:24 ` David Dunn
2022-02-10 13:29 ` Like Xu
2022-02-10 15:34 ` Liang, Kan
2022-02-10 16:34 ` Jim Mattson
2022-02-10 18:30 ` Liang, Kan
2022-02-10 19:16 ` Jim Mattson
2022-02-10 19:46 ` Liang, Kan
2022-02-10 19:55 ` David Dunn
2022-02-11 14:11 ` Liang, Kan
2022-02-11 18:08 ` Jim Mattson
2022-02-11 21:47 ` Liang, Kan
2022-02-12 23:31 ` Jim Mattson
2022-02-14 21:55 ` Liang, Kan
2022-02-14 22:55 ` Jim Mattson
2022-02-16 7:36 ` Like Xu
2022-02-16 18:10 ` Jim Mattson
2022-02-16 7:30 ` Like Xu
2022-02-16 5:08 ` Like Xu
2022-02-10 12:55 ` Like Xu
2022-02-12 23:32 ` Jim Mattson
2022-02-08 11:52 ` Like Xu
2022-01-17 8:53 ` [PATCH kvm/queue v2 3/3] KVM: x86/pmu: Setup the {inte|amd}_event_mapping[] when hardware_setup Like Xu
2022-02-01 12:28 ` Paolo Bonzini
2022-02-08 10:10 ` Like Xu
2022-01-26 11:22 ` [PATCH kvm/queue v2 0/3] KVM: x86/pmu: Fix out-of-date AMD amd_event_mapping[] Like Xu
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=20220202144308.GB20638@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=likexu@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.