Re: [PATCH] perf report: Display per-thread event counters

Ingo Molnar
2009-08-08T12:15:50Z

* Brice Goglin <Brice.Goglin@inria.fr> wrote:

> Here's a better patch. I moved everything to utils/values.[ch] so
> that we may reuse it in perf stat. [...]

Nice patch! I've applied it, you can find it in the latest -tip
tree:

http://people.redhat.com/mingo/tip.git/README

please send enhancements/fixes on top of this.

> [...] But I don't see yet where I am suppose to get something like
> PERF_READ_EVENT in builtin-stat.c so I haven't touched it yet.

Yeah. 'perf stat' is not really getting events but is doing a
read-out of the counter value(s) and constructs its 'read event'
that way. So you wont find PERF_READ_EVENT in builtin-stat.c, you'll
find:

res = read(fd[cpu][counter], single_count, nv * sizeof(u64));

in read_counter(). The printout is then done in print_counter().

> We get something like this now:
> # PID TID cache-misses cache-references
> 4658 4659 495581 3238779
> 4658 4662 498246 3236823
> 4658 4663 499531 3243162
>
> Then it'll be easy to add --pretty=raw to display a single line
> per thread/event.

ok.

> By the way, -S was also used for --symbol... So I used -T/--thread
> here.

Hm, indeed - and -s was taken for --sort. Maybe we could rename
-S/--symbols to -y/--symbols - this too is an i think rarely used
feature.

I think pure 'statistics' runs like you do will be a pretty popular
workflow, so intuitive naming/placement of options is important.

> perf report: Add -T/--threads to display per-thread counter values
>
> We get something like this now:
> # PID TID cache-misses cache-references
> 4658 4659 495581 3238779
> 4658 4662 498246 3236823
> 4658 4663 499531 3243162

Btw., another thing to do would be to allow the 'dual' recording of
both the stat values (collected when threads exit) and regular
samples that perf report deals with.

I.e. dont handle 'perf record -s' as an exclusive thing to regular
'perf record', but instead have -s/--sample-type option that can
have such combinations:

-s stats
-s samples
-s call-graph

And any combination thereof, such as:

-s stats,samples

The default would be '-s samples'. Right now call-graph recording is
triggered via a separate option (-g/--call-graph) - but maybe it
could be merged into a more generic -s/--sample option mechanism?

Ingo