Re: [PATCH 1/2] perf: Add munmap callback

From: Peter Zijlstra
Date: Wed Oct 24 2018 - 20:31:43 EST


On Wed, Oct 24, 2018 at 11:28:54AM -0700, Andi Kleen wrote:
> > > void perf_event_mmap(struct vm_area_struct *vma)
> > > {
> > > struct perf_mmap_event mmap_event;
> > >
> > > if (!atomic_read(&nr_mmap_events))
> > > return;
> > > <SNIP>
> > > }
> > >
> >
> > Thanks. I'll add the nr_mmap_events check in V2.
>
> No, that's the wrong check here. The PEBS flush is independent of mmap
> events being requested.
>
> If anything would need to check for any PEBS events active, which
> would need a new counter. I think the easiest is to just check if
> this_cpu_ptr(&sched_cb_list)
> is empty, which should be good enough.

It is just the CLI+STI, not PUSHF;CLI+POPF that are required and that is
a lot cheaper already. Also, you need to have preemption disabled in
order to check the per-cpu cb list.

So I don't think it really makes much sense to try and frob a fast path
in there.