Skip to content

Commit e89c5d1

Browse files
Dapeng MiPeter Zijlstra
authored andcommitted
perf/x86/intel: Update dyn_constraint base on PEBS event precise level
arch-PEBS provides CPUIDs to enumerate which counters support PEBS sampling and precise distribution PEBS sampling. Thus PEBS constraints should be dynamically configured base on these counter and precise distribution bitmap instead of defining them statically. Update event dyn_constraint base on PEBS event precise level. Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251029102136.61364-11-dapeng1.mi@linux.intel.com
1 parent 2721e8d commit e89c5d1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

arch/x86/events/intel/core.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,6 +4252,8 @@ static int intel_pmu_hw_config(struct perf_event *event)
42524252
}
42534253

42544254
if (event->attr.precise_ip) {
4255+
struct arch_pebs_cap pebs_cap = hybrid(event->pmu, arch_pebs_cap);
4256+
42554257
if ((event->attr.config & INTEL_ARCH_EVENT_MASK) == INTEL_FIXED_VLBR_EVENT)
42564258
return -EINVAL;
42574259

@@ -4265,6 +4267,15 @@ static int intel_pmu_hw_config(struct perf_event *event)
42654267
}
42664268
if (x86_pmu.pebs_aliases)
42674269
x86_pmu.pebs_aliases(event);
4270+
4271+
if (x86_pmu.arch_pebs) {
4272+
u64 cntr_mask = hybrid(event->pmu, intel_ctrl) &
4273+
~GLOBAL_CTRL_EN_PERF_METRICS;
4274+
u64 pebs_mask = event->attr.precise_ip >= 3 ?
4275+
pebs_cap.pdists : pebs_cap.counters;
4276+
if (cntr_mask != pebs_mask)
4277+
event->hw.dyn_constraint &= pebs_mask;
4278+
}
42684279
}
42694280

42704281
if (needs_branch_stack(event)) {

arch/x86/events/intel/ds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,7 @@ static void __init intel_arch_pebs_init(void)
30053005
x86_pmu.pebs_buffer_size = PEBS_BUFFER_SIZE;
30063006
x86_pmu.drain_pebs = intel_pmu_drain_arch_pebs;
30073007
x86_pmu.pebs_capable = ~0ULL;
3008+
x86_pmu.flags |= PMU_FL_PEBS_ALL;
30083009

30093010
x86_pmu.pebs_enable = __intel_pmu_pebs_enable;
30103011
x86_pmu.pebs_disable = __intel_pmu_pebs_disable;

0 commit comments

Comments
 (0)