Skip to content

Commit 1856c6c

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Thomas Falcon <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent c9449c8 commit 1856c6c

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

arch/x86/events/intel/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5069,6 +5069,16 @@ static void update_pmu_cap(struct x86_hybrid_pmu *pmu)
50695069
pmu->fixed_cntr_mask64 = fixed_cntr;
50705070
}
50715071

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+
50725082
if (!intel_pmu_broken_perf_cap()) {
50735083
/* Perf Metric (Bit 15) and PEBS via PT (Bit 16) are hybrid enumeration */
50745084
rdmsrl(MSR_IA32_PERF_CAPABILITIES, pmu->intel_cap.capabilities);

arch/x86/events/perf_event.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,15 @@ struct x86_hybrid_pmu {
708708
u64 fixed_cntr_mask64;
709709
unsigned long fixed_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
710710
};
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+
};
711720
struct event_constraint unconstrained;
712721

713722
u64 hw_cache_event_ids
@@ -806,6 +815,14 @@ struct x86_pmu {
806815
u64 fixed_cntr_mask64;
807816
unsigned long fixed_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
808817
};
818+
union {
819+
u64 acr_cntr_mask64;
820+
unsigned long acr_cntr_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
821+
};
822+
union {
823+
u64 acr_cause_mask64;
824+
unsigned long acr_cause_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
825+
};
809826
int cntval_bits;
810827
u64 cntval_mask;
811828
union {

arch/x86/include/asm/perf_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ union cpuid10_edx {
195195
*/
196196
#define ARCH_PERFMON_EXT_LEAF 0x00000023
197197
#define ARCH_PERFMON_NUM_COUNTER_LEAF 0x1
198+
#define ARCH_PERFMON_ACR_LEAF 0x2
198199

199200
union cpuid35_eax {
200201
struct {

0 commit comments

Comments
 (0)