lkml.org 
[lkml]   [2008]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [patch 0/3] [Announcement] Performance Counters for Linux
    From
    Date
    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?



    \
     
     \ /
      Last update: 2008-12-05 08:19    [W:0.029 / U:0.644 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site