Commit b3be39c5 authored by Thomas Richter's avatar Thomas Richter Committed by Arnaldo Carvalho de Melo

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: default avatarThomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: default avatarHendrik 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4cb7d3ec
...@@ -482,6 +482,34 @@ static void fs_something(void) ...@@ -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) static void do_something(void)
{ {
fs_something(); fs_something();
...@@ -592,10 +620,7 @@ static int do_test_code_reading(bool try_kcore) ...@@ -592,10 +620,7 @@ static int do_test_code_reading(bool try_kcore)
perf_evlist__set_maps(evlist, cpus, threads); perf_evlist__set_maps(evlist, cpus, threads);
if (excl_kernel) str = do_determine_event(excl_kernel);
str = "cycles:u";
else
str = "cycles";
pr_debug("Parsing event '%s'\n", str); pr_debug("Parsing event '%s'\n", str);
ret = parse_events(evlist, str, NULL); ret = parse_events(evlist, str, NULL);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment