On Thu, 19 Jun 2014 14:11:59 -0700 Andi Kleen <a...@firstfloor.org> wrote:
> Jesper Dangaard Brouer <jbro...@redhat.com> writes: > > > I want to use/read the PMU counters for 'instructions' and 'cycles', > > from within the kernel, to measure the overhead of different in-kernel > > functions (and calc the pipeline efficiency ala perf-stat insns per cycle). > > > > What is the prefered way/API to read these counters, without > > conflicting with the perf tool? > > > > perf_event_create_counter() Thanks, guess you mean: perf_event_create_kernel_counter() > > I basically just need a in-kernel API to turn in these counters, and > > then I can just read them via the rdpcm instruction. > > For RDPMC you would need extra support actually, as there is no > guarantee perf uses the fixed counter. In user space this > information is in the perf mmap page. Hmm, so you are saying that I cannot rely on just reading the counters with the "rdpmc" inctruction. What should I then use? I'm a little confused about the fixed counters, and the (to me) magic number that is used to read them: // From: https://github.com/andikleen/simple-pmu enum { FIXED_SELECT = (1U << 30), /* == 0x40000000 */ FIXED_INST_RETIRED_ANY = 0, FIXED_CPU_CLK_UNHALTED_CORE = 1, FIXED_CPU_CLK_UNHALTED_REF = 2, }; > Also please be aware that RDPMC is not synchronizing. What do you mean by "not synchronizing"? I've read some where, that I can use the "rdmsr" instruction in the kernel, and read the PCM register directly, to give me higher accuracy. Is that a bad idea? Thanks for your feedback, -- Best regards, Jesper Dangaard Brouer MSc.CS, Sr. Network Kernel Developer at Red Hat Author of http://www.iptv-analyzer.org LinkedIn: http://www.linkedin.com/in/brouer -- 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