Re: [PATCH 2/2] perf: Walk through the relevant events only

From: Frederic Weisbecker
Date: Fri Mar 05 2010 - 12:03:40 EST


On Fri, Mar 05, 2010 at 10:39:29AM +0100, Peter Zijlstra wrote:
> On Fri, 2010-03-05 at 08:00 +0100, Frederic Weisbecker wrote:
> > Each time a trace event triggers, we walk through the entire
> > list of events from the active contexts to find the perf events
> > that match the current one.
> >
> > This is wasteful. To solve this, we maintain a per cpu list of
> > the active perf events for each running trace events and we
> > directly commit to these.
>
> Right, so this seems a little trace specific. I once thought about using
> a hash table to do this for all software events. It also keeps it all
> nicely inside perf_event.[ch].


Right. We could have a per cpu type:event_id based hlist that would
cover trace events and other software events.

That would do the trick more generically wrt perf.

Now isn't the problem more in the fact that most of the swevents
should be tracepoints?

This is the case for most of them. Only PERF_COUNT_SW_CPU_CLOCK
and PERF_COUNT_SW_TASK_CLOCK seem to be the exception, and they
manage their own path by calling perf_event_overflow() directly.

And as you guess, turning them into tracepoints would benefit
to everyone. We'll have interesting trace events in fault paths,
we won't have zillions of hooks in the same place (in the context
switch, we have the usual tracepoint plus the perf call).
And eventually the off-case is better optimized, and further
optimizations there (jmp/nop patching/whatever) will propagate
to all tracepoint users.

Finally, we would have only one path to maintain for the swevents.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/