Re: [patch 0/3] [Announcement] Performance Counters for Linux

H. Peter Anvin
2008-12-05T00:28:18Z

Thomas Gleixner wrote:
>
> We'd like to announce a brand new implementation of performance counter
> support for Linux. It is a very simple and extensible design that has the
> potential to implement the full range of features we would expect from such
> a subsystem.
>

First of all, let me say I really like what I've seen so far. The file
descriptor paradigm seems really elegant to me.

> - Only one single new system call is needed: sys_perf_counter_open().
> All performance-counter operations are implemented via standard
> VFS APIs such as read() / fcntl() and poll().

As previously discussed, I think this should be a filesystem rather than
a system call. There are a couple of advantages to doing it that way, IMO:

- Strings, rather than numbers, which means fewer constraints across
architectures.
- The events available can be exported in the filesystem itself (via
readdir) rather than via sysfs.
- Compatibility with existing tools, esp. non-C tools.

I'm thinking of something like:

/dev/perfctr/3/cache_misses/all/simple/300

i.e. /dev/perfctr/<cpu>/<event>/<pid>/<type>/<period>. I am putting
<cpu> ahead of <event> in the hierarchy, so a readdir() on the <cpu>
directory can show the events available by name on that CPU. Raw
hardware events can be accessed by something like
/dev/perfctr/<cpu>/0x4064/...

-hpa