Re: [Patch v3 12/22] perf/x86/intel: Update dyn_constranit base on PEBS event precise level
From: Peter Zijlstra
Date: Wed Apr 16 2025 - 11:32:49 EST
On Tue, Apr 15, 2025 at 12:31:03PM -0400, Liang, Kan wrote:
> > This can land us in EVENT_CONSTRAINT_OVERLAP territory, no?
> The dyn_constraint is a supplement of the static constraints. It doesn't
> overwrite the static constraints.
That doesn't matter.
> In the intel_get_event_constraints(), perf always gets the static
> constraints first. If the dyn_constraint is defined, it gets the common
> mask of the static constraints and the dynamic constraints. All
> constraint rules will be complied.
>
> if (event->hw.dyn_constraint != ~0ULL) {
> c2 = dyn_constraint(cpuc, c2, idx);
> c2->idxmsk64 &= event->hw.dyn_constraint;
> c2->weight = hweight64(c2->idxmsk64);
> }
Read the comment that goes with EVENT_CONSTRAINT_OVERLAP().
Suppose we have (from intel_lnc_event_constraints[]):
INTEL_UEVENT_CONSTRAINT(0x012a, 0xf)
INTEL_EVENT_CONSTRAINT(0x2e, 0x3ff)
Then since the first is fully contained in the latter, there is no
problem.
Now imagine PEBS gets a dynamic constraint of 0x3c (just because), and
then you try and create a PEBS event along with the above two events,
and all of a sudden you have:
0x000f
0x003c
0x03ff
And that is exactly the problem case.
Also, looking at that LNC table, please explain:
INTEL_UEVENT_CONSTRAINT(0x01cd, 0x3fc)
that looks like the exact thing I've asked to never do, exactly because
of the above problem :-(