From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>,
Andi Kleen <andi@firstfloor.org>,
linux-perf-users@vger.kernel.org
Cc: Daniel Borkmann <dborkman@redhat.com>,
Florian Westphal <fw@strlen.de>,
Hannes Frederic Sowa <hannes@stressinduktion.org>
Subject: Use of PMU counters inside kernel?
Date: Thu, 19 Jun 2014 12:53:52 +0200 [thread overview]
Message-ID: <20140619125352.768e1ec9@redhat.com> (raw)
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
next reply other threads:[~2014-06-19 10:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 10:53 Jesper Dangaard Brouer [this message]
2014-06-19 21:11 ` Use of PMU counters inside kernel? Andi Kleen
2014-06-20 11:04 ` Jesper Dangaard Brouer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140619125352.768e1ec9@redhat.com \
--to=jbrouer@redhat.com \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=dborkman@redhat.com \
--cc=fw@strlen.de \
--cc=hannes@stressinduktion.org \
--cc=linux-perf-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox