Skip to content

Commit ffbe4ab

Browse files
Kan LiangIngo Molnar
Kan Liang
authored and
Ingo Molnar
committed
perf/x86/intel: Extend the ref-cycles event to GP counters
The current ref-cycles event is only available on the fixed counter 2. Starting from the GLC and GRT core, the architectural UnHalted Reference Cycles event (0x013c) which is available on general-purpose counters can collect the exact same events as the fixed counter 2. Update the mapping of ref-cycles to 0x013c. So the ref-cycles can be available on both fixed counter 2 and general-purpose counters. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 950ecdc commit ffbe4ab

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

arch/x86/events/intel/core.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ static struct event_constraint intel_slm_event_constraints[] __read_mostly =
211211
EVENT_CONSTRAINT_END
212212
};
213213

214+
static struct event_constraint intel_grt_event_constraints[] __read_mostly = {
215+
FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
216+
FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
217+
FIXED_EVENT_CONSTRAINT(0x0300, 2), /* pseudo CPU_CLK_UNHALTED.REF */
218+
FIXED_EVENT_CONSTRAINT(0x013c, 2), /* CPU_CLK_UNHALTED.REF_TSC_P */
219+
EVENT_CONSTRAINT_END
220+
};
221+
214222
static struct event_constraint intel_skl_event_constraints[] = {
215223
FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
216224
FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
@@ -314,6 +322,7 @@ static struct event_constraint intel_glc_event_constraints[] = {
314322
FIXED_EVENT_CONSTRAINT(0x0100, 0), /* INST_RETIRED.PREC_DIST */
315323
FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
316324
FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */
325+
FIXED_EVENT_CONSTRAINT(0x013c, 2), /* CPU_CLK_UNHALTED.REF_TSC_P */
317326
FIXED_EVENT_CONSTRAINT(0x0400, 3), /* SLOTS */
318327
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_RETIRING, 0),
319328
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_BAD_SPEC, 1),
@@ -5983,6 +5992,12 @@ static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
59835992
return 0;
59845993
}
59855994

5995+
static __always_inline void intel_pmu_ref_cycles_ext(void)
5996+
{
5997+
if (!(x86_pmu.events_maskl & (INTEL_PMC_MSK_FIXED_REF_CYCLES >> INTEL_PMC_IDX_FIXED)))
5998+
intel_perfmon_event_map[PERF_COUNT_HW_REF_CPU_CYCLES] = 0x013c;
5999+
}
6000+
59866001
static __always_inline void intel_pmu_init_glc(struct pmu *pmu)
59876002
{
59886003
x86_pmu.late_ack = true;
@@ -6005,6 +6020,8 @@ static __always_inline void intel_pmu_init_glc(struct pmu *pmu)
60056020
memcpy(hybrid_var(pmu, hw_cache_extra_regs), glc_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
60066021
hybrid(pmu, event_constraints) = intel_glc_event_constraints;
60076022
hybrid(pmu, pebs_constraints) = intel_glc_pebs_event_constraints;
6023+
6024+
intel_pmu_ref_cycles_ext();
60086025
}
60096026

60106027
static __always_inline void intel_pmu_init_grt(struct pmu *pmu)
@@ -6021,9 +6038,11 @@ static __always_inline void intel_pmu_init_grt(struct pmu *pmu)
60216038
memcpy(hybrid_var(pmu, hw_cache_event_ids), glp_hw_cache_event_ids, sizeof(hw_cache_event_ids));
60226039
memcpy(hybrid_var(pmu, hw_cache_extra_regs), tnt_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
60236040
hybrid_var(pmu, hw_cache_event_ids)[C(ITLB)][C(OP_READ)][C(RESULT_ACCESS)] = -1;
6024-
hybrid(pmu, event_constraints) = intel_slm_event_constraints;
6041+
hybrid(pmu, event_constraints) = intel_grt_event_constraints;
60256042
hybrid(pmu, pebs_constraints) = intel_grt_pebs_event_constraints;
60266043
hybrid(pmu, extra_regs) = intel_grt_extra_regs;
6044+
6045+
intel_pmu_ref_cycles_ext();
60276046
}
60286047

60296048
__init int intel_pmu_init(void)

0 commit comments

Comments
 (0)