I modified Perf Stat to enable it to sample the performance counters periodically. To do this, I moved the sampling portion of the code into the while block. While this works, I seem to get some erroneous data; such as cycle counter being the same whereas instruction counter increased.
while(!done) { nanosleep(&delay,NULL); update_stats(&walltime_nsecs_stats, (rdclock() - t0)); if (no_aggr) { list_for_each_entry(counter, &evsel_list->entries, node) { read_counter(counter); } } else { list_for_each_entry(counter, &evsel_list->entries, node) { read_counter_aggr(counter); } if(verbose) fprintf(stdout , "\n\n"); } } The command that I use to do this is perf stat -e cycles,instructions -p <pid> I believe this is because a context switch to the process being monitored happens after perf reads the first counter (cycles). Hence, after the context switch, when perf runs, it reads the instruction counter which has moved ahead (as the process executed upon context switching). This causes the cycle counter to reflect no change in this sample whereas the instruction counter changed. Is there any way to circumvent this issue? -- To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html