From: tip-bot for Thomas Richter <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tmricht@linux.vnet.ibm.com, brueckner@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org, tglx@linutronix.de,
acme@redhat.com, heiko.carstens@de.ibm.com, hpa@zytor.com,
schwidefsky@de.ibm.com, mingo@kernel.org
Subject: [tip:perf/core] perf test: Fix test case 23 for s390 z/VM or KVM guests
Date: Sat, 17 Feb 2018 03:38:46 -0800 [thread overview]
Message-ID: <tip-b3be39c51cc58eb60c698cf64987e9d465a9263a@git.kernel.org> (raw)
In-Reply-To: <20180213151419.80737-4-tmricht@linux.vnet.ibm.com>
Commit-ID: b3be39c51cc58eb60c698cf64987e9d465a9263a
Gitweb: https://git.kernel.org/tip/b3be39c51cc58eb60c698cf64987e9d465a9263a
Author: Thomas Richter <tmricht@linux.vnet.ibm.com>
AuthorDate: Tue, 13 Feb 2018 16:14:19 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 16 Feb 2018 15:16:57 -0300
perf test: Fix test case 23 for s390 z/VM or KVM guests
On s390 perf can be executed on a LPAR with support for hardware events
(i. e. cycles) or on a z/VM or KVM guest where no hardware events are
supported. In this environment use software event named cpu-clock for
this test case.
Use the cpuid infrastructure functions to determine the cpuid on s390
which contains an indication of the cpu counter facility availability.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/20180213151419.80737-4-tmricht@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/code-reading.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 3bf7b14..c7115d3 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -482,6 +482,34 @@ static void fs_something(void)
}
}
+static const char *do_determine_event(bool excl_kernel)
+{
+ const char *event = excl_kernel ? "cycles:u" : "cycles";
+
+#ifdef __s390x__
+ char cpuid[128], model[16], model_c[16], cpum_cf_v[16];
+ unsigned int family;
+ int ret, cpum_cf_a;
+
+ if (get_cpuid(cpuid, sizeof(cpuid)))
+ goto out_clocks;
+ ret = sscanf(cpuid, "%*[^,],%u,%[^,],%[^,],%[^,],%x", &family, model_c,
+ model, cpum_cf_v, &cpum_cf_a);
+ if (ret != 5) /* Not available */
+ goto out_clocks;
+ if (excl_kernel && (cpum_cf_a & 4))
+ return event;
+ if (!excl_kernel && (cpum_cf_a & 2))
+ return event;
+
+ /* Fall through: missing authorization */
+out_clocks:
+ event = excl_kernel ? "cpu-clock:u" : "cpu-clock";
+
+#endif
+ return event;
+}
+
static void do_something(void)
{
fs_something();
@@ -592,10 +620,7 @@ static int do_test_code_reading(bool try_kcore)
perf_evlist__set_maps(evlist, cpus, threads);
- if (excl_kernel)
- str = "cycles:u";
- else
- str = "cycles";
+ str = do_determine_event(excl_kernel);
pr_debug("Parsing event '%s'\n", str);
ret = parse_events(evlist, str, NULL);
if (ret < 0) {
next prev parent reply other threads:[~2018-02-17 11:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 15:14 [PATCH 1/4] perf record: Provide detailed information on s390 CPU Thomas Richter
2018-02-13 15:14 ` [PATCH 2/4] perf annotate: Scan cpuid for s390 and save machine type Thomas Richter
2018-02-17 11:37 ` [tip:perf/core] " tip-bot for Thomas Richter
2018-02-13 15:14 ` [PATCH 3/4] perf cpuid: Introduce a platform specfic cpuid compare function Thomas Richter
2018-02-17 11:38 ` [tip:perf/core] perf cpuid: Introduce a platform specific " tip-bot for Thomas Richter
2018-02-13 15:14 ` [PATCH 4/4] perf test: Fix test case 23 for s390 z/VM or KVM guests Thomas Richter
2018-02-17 11:38 ` tip-bot for Thomas Richter [this message]
2018-02-15 14:50 ` [PATCH 1/4] perf record: Provide detailed information on s390 CPU Arnaldo Carvalho de Melo
2018-02-16 16:55 ` Arnaldo Carvalho de Melo
2018-02-16 18:17 ` Arnaldo Carvalho de Melo
2018-02-17 11:37 ` [tip:perf/core] " tip-bot for Thomas Richter
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=tip-b3be39c51cc58eb60c698cf64987e9d465a9263a@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=brueckner@linux.vnet.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
--cc=tmricht@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox