Re: [RFC PATCH 1/1] kernel/events: Introduce IOC_COUNT_RECORDS
From: Naveen N. Rao
Date: Tue Jun 06 2017 - 13:13:47 EST
Hi Peter,
On 2017/06/06 06:17PM, Peter Zijlstra wrote:
> On Tue, Jun 06, 2017 at 08:46:28PM +0530, Naveen N. Rao wrote:
> > Many perf sideband events (context switches, namespaces, ...) are useful
> > by themselves without the need for subscribing to any overflow events.
> > However, it is not possible to subscribe for notifications when such
> > records are logged into the ring buffer. Introduce IOC_COUNT_RECORDS as
> > a way to request this.
> >
> > With IOC_COUNT_RECORDS set, IOC_REFRESH takes the number of records
> > after which to generate a notification, rather than the number of
> > overflow events.
>
> You forgot to explain why? As is I'm not terribly excited to have more
> 'crud' in that output path.
The usecase is a process wanting to profile itself for context switches.
Currently, there is no way to ask for signals to be delivered for
PERF_RECORD_SWITCH (or, other sideband) events, except setting
{watermark=1, wakeup_watermark=1} and using poll()/select(). But, for
self-profiling, that requires a separate thread to be used.
In addition, it would be easier for user-space to ask for notification
after a certain number of records, rather than a certain number of
bytes. This is specifically important for context switch events, since
we would otherwise not be able to block (context switch out would
generate an event which would wake us up immediately, interrupting any
existing system calls).
I have included an example program in the cover letter which
demonstrates this scenario.
For the above reasons, I felt it would be simpler to extend the use of
IOC_REFRESH ioctl.
- Naveen