From: Guru Prasad <gurupras@buffalo.edu>
To: linux-perf-users@vger.kernel.org
Subject: Sampling the perf counters
Date: Sun, 16 Dec 2012 11:29:32 -0500 [thread overview]
Message-ID: <CAMefCkCMj2XNE15u9QEMKW0=0HU=QS3KLyxiyK40Zb-qaZxt6w@mail.gmail.com> (raw)
In-Reply-To: <CAMefCkBP4-We-jGet6EaWDGcztvMiKPsVBVVs7d3hyxOncSzFg@mail.gmail.com>
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?
parent reply other threads:[~2012-12-16 16:29 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAMefCkBP4-We-jGet6EaWDGcztvMiKPsVBVVs7d3hyxOncSzFg@mail.gmail.com>]
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='CAMefCkCMj2XNE15u9QEMKW0=0HU=QS3KLyxiyK40Zb-qaZxt6w@mail.gmail.com' \
--to=gurupras@buffalo.edu \
--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;
as well as URLs for NNTP newsgroup(s).