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

From: Ingo Molnar
Date: Sat Aug 08 2009 - 12:14:03 EST



* Brice Goglin <Brice.Goglin@xxxxxxxx> wrote:

> Ingo Molnar wrote:
> >> [...] 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().
>
> Is there a way to get per-thread counters there? I wrote the code
> to gather per-cpu counters there, but I don't see any way to get
> the corresponding thread-id.
>
> I looked at perf record to get some help. But I don't see where
> the PERF_EVENT_READ are generated. I guess they are directly
> generated by the kernel, read by perf record, and written as is to
> the output file?

Inherited counters are not accessible to the parent context. (they
dont even have any fds instantiated, for performance and
transparency reasons.)

I think perf stat could be enhanced to work not via reading the raw
counters but by doing a mini "perf-record" internally, mmap the
samples buffer and getting all the events there?

Ingo
--
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/