From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>,
lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Namhyung Kim <namhyung@kernel.org>,
David Ahern <dsahern@gmail.com>, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 1/2] perf tests: Fix switch tracking test for P4
Date: Fri, 26 May 2017 14:31:40 +0200 [thread overview]
Message-ID: <20170526123141.20900-1-jolsa@kernel.org> (raw)
The switch tracking test keeps failing on P4 cpu,
when NMI watchdog is enabled.
The reason is that P4 pmu uses substitute event for cycles
when it's already taken (in our case by NMI watchdog), but
this event does not give even results like cycles, and we
could end up with no samples at all for our short
measuring period.
Fixing this by using "instructions:u" event instead,
which seems to be stable enough.
Cc: Michael Petlan <mpetlan@redhat.com>
Link: http://lkml.kernel.org/n/tip-4s8vo7skneszacdckv7uiog3@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/tests/switch-tracking.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 65474fd80da7..e519819ea2e5 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -10,6 +10,7 @@
#include "thread_map.h"
#include "cpumap.h"
#include "tests.h"
+#include "header.h"
static int spin_sleep(void)
{
@@ -298,6 +299,27 @@ static int process_events(struct perf_evlist *evlist,
return ret;
}
+static const char *get_hw_counter(void)
+{
+ const char *counter = "cycles:u";
+ char *cpuid;
+
+ cpuid = get_cpuid_str();
+
+ /*
+ * P4 pmu uses substitute event for cycles if it's already
+ * taken, but it does not give even results like cycles,
+ * and we could end up with no samples at all for our short
+ * measuring period. Using "instructions:u" event instead,
+ * which seems to be stable enough.
+ */
+ if (!strcmp("GenuineIntel-15-4", cpuid))
+ counter = "instructions:u";
+
+ pr_debug("using '%s' HW counter");
+ return counter;
+}
+
/**
* test__switch_tracking - test using sched_switch and tracking events.
*
@@ -308,6 +330,7 @@ static int process_events(struct perf_evlist *evlist,
*/
int test__switch_tracking(int subtest __maybe_unused)
{
+ const char *hw_counter = get_hw_counter();
const char *sched_switch = "sched:sched_switch";
struct switch_tracking switch_tracking = { .tids = NULL, };
struct record_opts opts = {
@@ -357,9 +380,9 @@ int test__switch_tracking(int subtest __maybe_unused)
cpu_clocks_evsel = perf_evlist__last(evlist);
/* Second event */
- err = parse_events(evlist, "cycles:u", NULL);
+ err = parse_events(evlist, hw_counter, NULL);
if (err) {
- pr_debug("Failed to parse event cycles:u\n");
+ pr_debug("Failed to parse event %s\n", hw_counter);
goto out_err;
}
--
2.9.4
next reply other threads:[~2017-05-26 12:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 12:31 Jiri Olsa [this message]
2017-05-26 12:31 ` [PATCH 2/2] perf tests: Rename cycles event to HW event Jiri Olsa
2017-06-01 13:11 ` [PATCH 1/2] perf tests: Fix switch tracking test for P4 Arnaldo Carvalho de Melo
2017-06-02 11:35 ` Adrian Hunter
2017-06-04 19:09 ` Jiri Olsa
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=20170526123141.20900-1-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@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