Re: [PATCH 2/6 -tip] perf stat: treat same behaviour for all CYCLES and CLOCKS

Ingo Molnar
2009-07-03T08:28:14Z

* Paul Mackerras <paulus@samba.org> wrote:

> Ingo Molnar writes:
>
> > Other 'compound' events might be possible too: for example a new
> > cache-hits field could be is cache-refs minus cache-misses.
>
> Hmmm, on the MPC7450 family there are events for cache-hits and
> cache-misses, so there it would be nice to be able to ask for
> cache-refs and have it compute cache-hits plus cache-misses.

Yes. I think the API is structured enough so that user-space knows
enough about the meaning of the events here. We can certainly
stipulate this rule:

refs == hits + misses

And if the kernel returns -ENODEV for a particular component
user-space can fall back using the other two events.

I.e. this would allow transparent support for all 3 permutations:

hw has refs and hits
hw has refs and misses
hw has hits and misses

For sampling it's a tiny bit tricky but still doable:j a compound
counter could still sample because we handle weighted samples
throughout the tools and negative weight can be subtraced.

Intuitive annotation output would have to be thought out for this as
entries/function could go negative statistically.

> > I.e. the simplest model for 'compound' events would be:
> >
> > X = A / B
> > X = A - B
> > X = A + B
> >
> > We could list them in the event table, with a flag that
> > specifies which arithmetic operation connects two 'atomic'
> > counters.
> >
> > Then the adding of a new compound event would only be the matter
> > of adding one more line to the event table.
>
> Sounds nice. If we do this we should ensure that the two events
> get put into one group if possible.

Correct. Are you interested in adding this, so that it fits the
MPC7450 family perfectly?

Ingo