Re: [RFC][PATCH 0/6] perf: x86 RDPMC and RDTSC support

From: Vince Weaver
Date: Wed Dec 21 2011 - 16:32:38 EST


On Wed, 21 Dec 2011, Vince Weaver wrote:
>
> currently when I tried doing a start ioctl then an immediate read, the
> counter values returned were a very high value. So unless I did two
> rdpmcs and subtracted, the results made no sense.

I've added two rdpmc() tests to my perf_event_test suite. A few comments.

* One, is it possible to detect at runtime that rdpmc() is supported?
Maybe a field in the mmap'd buffer that can be read?

Otherwise if you try to do a rdpmc() on an unpatched kernel you get a
general protection error and a segfault. This makes it tricky to have
nice code that tries rdpmc() and falls back to read() if it is
unavailable.

* Second, if I try a start / run 100M instructions / read
and measure retired instructions I get:
281474977711543 instructions
This is 0x10000000f45b7 which is 1<<48 + 100M. I guess an artifact
of how the counters are set up? Is it possible to have this start
at 0?

Otherwise you need to always do two reads and a subtract to get good
values.

Thanks,

Vince


(below are the results from the rdpmc_validation test)


This test checks if userspace rdpmc() style reads work.

total start/work/read/stop latency: 646001 cycles
Event 0 -- count: 281474977711543 running: 320324
Event 1 -- count: 281474977712320 running: 320939
total start/read/work/read/stop latency: 653451 cycles
Event 0 -- count: 1000828 running: 321985
Event 1 -- count: 1000108 running: 321195

Expected: 1000000
High: 1000828 Low: 1000828 Average: 1000828
( note, a small value above 1000000 may be expected due
to overhead and interrupt noise, among other reasons)
Average Error = 0.08%
Testing if userspace rdpmc reads give expected results... PASSED

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