From: kan.liang@linux.intel.com
To: peterz@infradead.org, mingo@kernel.org, acme@kernel.org,
namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org
Cc: ak@linux.intel.com, eranian@google.com,
Kan Liang <kan.liang@linux.intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [PATCH V3 06/13] perf/x86: Add config_mask to represent EVENTSEL bitmask
Date: Wed, 26 Jun 2024 07:35:38 -0700 [thread overview]
Message-ID: <20240626143545.480761-7-kan.liang@linux.intel.com> (raw)
In-Reply-To: <20240626143545.480761-1-kan.liang@linux.intel.com>
From: Kan Liang <kan.liang@linux.intel.com>
Different vendors may support different fields in EVENTSEL MSR, such as
Intel would introduce new fields umask2 and eq bits in EVENTSEL MSR
since Perfmon version 6. However, a fixed mask X86_RAW_EVENT_MASK is
used to filter the attr.config.
Introduce a new config_mask to record the real supported EVENTSEL
bitmask.
Only apply it to the existing code now. No functional change.
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Co-developed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
arch/x86/events/core.c | 5 ++++-
arch/x86/events/intel/core.c | 1 +
arch/x86/events/perf_event.h | 7 +++++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 0c51cfdf7609..842dbf1d706c 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -624,7 +624,7 @@ int x86_pmu_hw_config(struct perf_event *event)
event->hw.config |= ARCH_PERFMON_EVENTSEL_OS;
if (event->attr.type == event->pmu->type)
- event->hw.config |= event->attr.config & X86_RAW_EVENT_MASK;
+ event->hw.config |= x86_pmu_get_event_config(event);
if (event->attr.sample_period && x86_pmu.limit_period) {
s64 left = event->attr.sample_period;
@@ -2098,6 +2098,9 @@ static int __init init_hw_perf_events(void)
if (!x86_pmu.intel_ctrl)
x86_pmu.intel_ctrl = x86_pmu.cntr_mask64;
+ if (!x86_pmu.config_mask)
+ x86_pmu.config_mask = X86_RAW_EVENT_MASK;
+
perf_events_lapic_init();
register_nmi_handler(NMI_LOCAL, perf_event_nmi_handler, 0, "PMI");
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 3bf3d6b619ed..12b78febcd09 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -6144,6 +6144,7 @@ static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
pmu->cntr_mask64 = x86_pmu.cntr_mask64;
pmu->fixed_cntr_mask64 = x86_pmu.fixed_cntr_mask64;
pmu->pebs_events_mask = intel_pmu_pebs_mask(pmu->cntr_mask64);
+ pmu->config_mask = X86_RAW_EVENT_MASK;
pmu->unconstrained = (struct event_constraint)
__EVENT_CONSTRAINT(0, pmu->cntr_mask64,
0, x86_pmu_num_counters(&pmu->pmu), 0, 0);
diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
index 0d333bb9c8f4..a226565a9333 100644
--- a/arch/x86/events/perf_event.h
+++ b/arch/x86/events/perf_event.h
@@ -695,6 +695,7 @@ struct x86_hybrid_pmu {
union perf_capabilities intel_cap;
u64 intel_ctrl;
u64 pebs_events_mask;
+ u64 config_mask;
union {
u64 cntr_mask64;
unsigned long cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
@@ -790,6 +791,7 @@ struct x86_pmu {
int (*rdpmc_index)(int index);
u64 (*event_map)(int);
int max_events;
+ u64 config_mask;
union {
u64 cntr_mask64;
unsigned long cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
@@ -1241,6 +1243,11 @@ static inline int x86_pmu_max_num_counters_fixed(struct pmu *pmu)
return find_last_bit(hybrid(pmu, fixed_cntr_mask), INTEL_PMC_MAX_FIXED) + 1;
}
+static inline u64 x86_pmu_get_event_config(struct perf_event *event)
+{
+ return event->attr.config & hybrid(event->pmu, config_mask);
+}
+
extern struct event_constraint emptyconstraint;
extern struct event_constraint unconstrained;
--
2.38.1
next prev parent reply other threads:[~2024-06-26 14:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 14:35 [PATCH V3 00/13] Support Lunar Lake and Arrow Lake core PMU kan.liang
2024-06-26 14:35 ` [PATCH V3 01/13] perf/x86/intel: Support the PEBS event mask kan.liang
2024-06-28 8:42 ` Peter Zijlstra
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 02/13] perf/x86: Support counter mask kan.liang
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 03/13] perf/x86: Add Lunar Lake and Arrow Lake support kan.liang
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 04/13] perf/x86/intel: Rename model-specific pebs_latency_data functions kan.liang
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 05/13] perf/x86/intel: Support new data source for Lunar Lake kan.liang
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` kan.liang [this message]
2024-07-05 21:06 ` [tip: perf/core] perf/x86: Add config_mask to represent EVENTSEL bitmask tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 07/13] perf/x86/intel: Support PERFEVTSEL extension kan.liang
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 08/13] perf/x86/intel: Support Perfmon MSRs aliasing kan.liang
2024-07-05 21:06 ` [tip: perf/core] " tip-bot2 for Kan Liang
2024-06-26 14:35 ` [PATCH V3 09/13] perf/x86: Extend event update interface kan.liang
2024-06-26 14:35 ` [PATCH V3 10/13] perf: Extend perf_output_read kan.liang
2024-06-26 14:35 ` [PATCH V3 11/13] perf/x86/intel: Move PEBS event update after the sample output kan.liang
2024-06-26 14:35 ` [PATCH V3 12/13] perf/x86/intel: Support PEBS counters snapshotting kan.liang
2024-06-26 14:35 ` [PATCH V3 13/13] perf/x86/intel: Support RDPMC metrics clear mode kan.liang
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=20240626143545.480761-7-kan.liang@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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