All of lore.kernel.org
 help / color / mirror / Atom feed
* Use of PMU counters inside kernel?
@ 2014-06-19 10:53 Jesper Dangaard Brouer
  2014-06-19 21:11 ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2014-06-19 10:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Andi Kleen, linux-perf-users
  Cc: Daniel Borkmann, Florian Westphal, Hannes Frederic Sowa

Hi

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?


I've already looked at Andi Kleens "simple-pmu" kernel module
 https://github.com/andikleen/simple-pmu/
Thus, I have figured out how I can hack this together open-coded. I'm
looking for advice on howto use the existing perf APIs ?

I basically just need a in-kernel API to turn in these counters, and
then I can just read them via the rdpcm instruction.


Info I already learned (correct me if I'm wrong):

The 'instructions' counter is the "Instruction Retired" counter
 * Event num: 0xC0, Umask: 0x00
 * Read via rdpmc 0x40000000

The 'cycles' counter is the "Unhalted core cycles" counter
 * Event num: 0x3C, Umask: 0x00
 * Read via rdpmc 0x40000001

I'm uncertain about the rdpmc hex values (taken from simple-pmu).

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-20 11:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 10:53 Use of PMU counters inside kernel? Jesper Dangaard Brouer
2014-06-19 21:11 ` Andi Kleen
2014-06-20 11:04   ` Jesper Dangaard Brouer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.