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

From: Peter Zijlstra
Date: Fri Dec 05 2008 - 02:16:44 EST


On Fri, 2008-12-05 at 08:03 +0100, Ingo Molnar wrote:

> int main(void)
> {
> unsigned long long count1, count2;
> int fd1, fd2, ret;
>
> fd1 = perf_counter_open(PERF_COUNT_INSTRUCTIONS, 0, 0, 0, -1);
> assert(fd1 >= 0);
> fd2 = perf_counter_open(PERF_COUNT_CACHE_MISSES, 0, 0, 0, -1);
> assert(fd1 >= 0);
>
> for (;;) {
> ret = read(fd1, &count1, sizeof(count1));
> assert(ret == 8);
> ret = read(fd2, &count2, sizeof(count2));
> assert(ret == 8);
>
> printf("counter1 value: %Ld instructions\n", count1);
> printf("counter2 value: %Ld cachemisses\n", count2);
> sleep(1);
> }
> return 0;
> }

So, while most people would not consider two consecutive read() ops to
be close or near the same time, due to preemption and such, that is
taken away by the fact that the counters are task local time based - so
preemption doesn't affect thing. Right?

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