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

From: H. Peter Anvin
Date: Thu Dec 04 2008 - 19:28:19 EST


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