Re: [PATCH] perf/headers: Document PERF_PMU_CAP capability flags

From: Peter Zijlstra
Date: Fri Jun 20 2025 - 04:04:58 EST


On Thu, Jun 19, 2025 at 06:06:50PM +0200, Nicolas Frattaroli wrote:

> > > #define PERF_PMU_CAP_NO_INTERRUPT 0x0001
> >
> > This is not quite right; CAP_NO_INTERRUPT means it is not able to
> > generate samples.
> >
> > While not being able to generate interrupts and not being able to
> > generate sample is more or less the same for CPU PMU drivers, this is
> > not true for uncore drivers. Even if an uncore driver has interrupt
> > capacility to help with counter overflow, it cannot generate samples.
>
> I'll send a follow-up v2 to fix this, though just to make sure I
> understand this right, I have some questions for clarification.
>
> Does "uncore" in this context mean PMU drivers for counters that are not
> tied to the CPU instruction flow, but are counting other things like
> interconnect statistics?

Correct.

> Also, am I correct in assuming "sample" in this context means the
> concept represented by struct perf_sample_data, i.e. what appears to be
> a snapshot of current process context, including registers and stack
> information?

Right; perf_event_attr::sample_type, filled out with bits from
perf_event_sample_format.

> Which would then mean going by my understanding of uncore
> that basically every uncore driver should set this capability flag, as
> they're not performance counter registers on a CPU that are intimately
> tied to the ISAs execution state.

Correct again. There is interconnect, memory and even GPU drivers out
there these days.

> To further my understanding: does this mean that
> drivers/devfreq/event/rockchip-dfi.c (used for measuring memory
> bandwidth) should set PERF_PMU_CAP_NO_INTERRUPT, since it's not a CPU
> but a memory controller monitor?

Yup, that would indeed seem to be so.

> In a more general sense, if anyone has any written resources on writing
> PMU drivers, rather than perf from a userspace perspective, I'd be very
> happy to get some pointers in their direction.

I'm afraid not :/ The best we have is the comments in struct pmu.