Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf/x86/intel: Add CPUID enumeration for the auto counter reload

The counters that support the auto counter reload feature can be
enumerated in the CPUID Leaf 0x23 sub-leaf 0x2.

Add acr_cntr_mask to store the mask of counters which are reloadable.
Add acr_cause_mask to store the mask of counters which can cause reload.
Since the e-core and p-core may have different numbers of counters,
track the masks in the struct x86_hybrid_pmu as well.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Link: https://lkml.kernel.org/r/20250327195217.2683619-5-kan.liang@linux.intel.com

authored by

Kan Liang and committed by
Peter Zijlstra
1856c6c2 c9449c85

+28
+10
arch/x86/events/intel/core.c
··· 5069 5069 pmu->fixed_cntr_mask64 = fixed_cntr; 5070 5070 } 5071 5071 5072 + if (eax.split.acr_subleaf) { 5073 + cpuid_count(ARCH_PERFMON_EXT_LEAF, ARCH_PERFMON_ACR_LEAF, 5074 + &cntr, &fixed_cntr, &ecx, &edx); 5075 + /* The mask of the counters which can be reloaded */ 5076 + pmu->acr_cntr_mask64 = cntr | ((u64)fixed_cntr << INTEL_PMC_IDX_FIXED); 5077 + 5078 + /* The mask of the counters which can cause a reload of reloadable counters */ 5079 + pmu->acr_cause_mask64 = ecx | ((u64)edx << INTEL_PMC_IDX_FIXED); 5080 + } 5081 + 5072 5082 if (!intel_pmu_broken_perf_cap()) { 5073 5083 /* Perf Metric (Bit 15) and PEBS via PT (Bit 16) are hybrid enumeration */ 5074 5084 rdmsrl(MSR_IA32_PERF_CAPABILITIES, pmu->intel_cap.capabilities);
+17
arch/x86/events/perf_event.h
··· 708 708 u64 fixed_cntr_mask64; 709 709 unsigned long fixed_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 710 710 }; 711 + 712 + union { 713 + u64 acr_cntr_mask64; 714 + unsigned long acr_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 715 + }; 716 + union { 717 + u64 acr_cause_mask64; 718 + unsigned long acr_cause_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 719 + }; 711 720 struct event_constraint unconstrained; 712 721 713 722 u64 hw_cache_event_ids ··· 814 805 union { 815 806 u64 fixed_cntr_mask64; 816 807 unsigned long fixed_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 808 + }; 809 + union { 810 + u64 acr_cntr_mask64; 811 + unsigned long acr_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 812 + }; 813 + union { 814 + u64 acr_cause_mask64; 815 + unsigned long acr_cause_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)]; 817 816 }; 818 817 int cntval_bits; 819 818 u64 cntval_mask;
+1
arch/x86/include/asm/perf_event.h
··· 195 195 */ 196 196 #define ARCH_PERFMON_EXT_LEAF 0x00000023 197 197 #define ARCH_PERFMON_NUM_COUNTER_LEAF 0x1 198 + #define ARCH_PERFMON_ACR_LEAF 0x2 198 199 199 200 union cpuid35_eax { 200 201 struct {