Re: [PATCH v3 1/3] perf: Add PERF_EVENT_IOC_INC_EVENT_LIMIT

From: Charlie Jenkins
Date: Mon Jan 13 2025 - 13:59:44 EST


On Mon, Jan 13, 2025 at 02:18:12PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 06, 2025 at 08:07:32PM -0800, Charlie Jenkins wrote:
> > PERF_EVENT_IOC_REFRESH immediately enables after incrementing
> > event_limit. Provide a new ioctl flag that allows programs to increment
> > event_limit without enabling the event. A usecase for this is to set an
> > event_limit in combination with enable_on_exec.
>
>
> Utter lack of WHY.

My usecase is being able to use libperf to calculate performance metrics
from running a program for X number of instructions.
PERF_EVENT_IOC_REFRESH can be used to stop the counters after the
instruction sampling threshold has been hit. This requires being able to
start PERF_EVENT_IOC_REFRESH as soon as the program starts executing,
which is a perfect application for enable_on_exec.

- Charlie