From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
linux-perf-users@vger.kernel.org,
Daniel Borkmann <dborkman@redhat.com>,
Florian Westphal <fw@strlen.de>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
Richard Fowles <rfowles@redhat.com>
Subject: Re: Use of PMU counters inside kernel?
Date: Fri, 20 Jun 2014 13:04:03 +0200 [thread overview]
Message-ID: <20140620130403.5ed22a73@redhat.com> (raw)
In-Reply-To: <87d2e48uzk.fsf@tassilo.jf.intel.com>
On Thu, 19 Jun 2014 14:11:59 -0700
Andi Kleen <andi@firstfloor.org> wrote:
> Jesper Dangaard Brouer <jbrouer@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
prev parent reply other threads:[~2014-06-20 11:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20140620130403.5ed22a73@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 \
--cc=rfowles@redhat.com \
/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 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.