[dropped all these bouncing email lists. Adding closed lists to public
cc lists is just a bad idea]
There's nothing in your example that makes the file descriptor needed.
That would be nicer if it was just two arguments.
Why do you need to set the data register? Wouldn't it make
more sense to let the kernel handle that and just return one.
My replacement would be to just add a flags argument to write_pmcs
with one flag bit meaning "GLOBAL CONTEXT" versus "MY CONTEXT"
Why can't that be done by the call setting up the register?
Or if someone needs to do it for a specific region they can read
the register before and then afterwards.
On x86 i think it would be much simpler to just let the set/alloc
register call return a number and then use RDPMC directly. That would
be actually faster and be much simpler too.
I suppose most architectures have similar facilities, if not a call could be
added for them but it's not really essential. The call might be also needed
for event multiplexing, but frankly I would just leave that out for now.
e.g. here is one use case I would personally see as useful. We need
a replacement for simple cycle counting since RDTSC doesn't do that anymore
on modern x86 CPUs. It could be something like:
/* 0 is the initial value */
/* could be either library or syscall */
event = get_event(COUNTER_CYCLES);
if (event < 0)
/* CPU has no cycle counter */
reg = setup_perfctr(event, 0 /* value */, LOCAL_EVENT); /* syscall */
rdpmc(reg, start);
.... some code to run ...
rdpmc(reg, end);
free_perfctr(reg); /* syscall */
On other architectures rdpmc would be different of course, but
the rest could be probably similar.
-Andi
-