* [PATCH] perf test: Add parse-metric memory bandwidth testcase
@ 2021-01-25 12:47 John Garry
2021-02-03 4:24 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: John Garry @ 2021-01-25 12:47 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, irogers, kjain
Cc: linux-kernel, linuxarm, John Garry
Event duration_time in a metric expression requires special handling.
Improve test coverage by including a metric whose expression includes
duration_time. The actual metric is a copied from the L1D_Cache_Fill_BW
metric on my broadwell machine.
Signed-off-by: John Garry <john.garry@huawei.com>
---
Based on acme perf/core + "perf metricgroup: Fix for metrics containing duration_time"
diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c
index ce7be37f0d88..6dc1db1626ad 100644
--- a/tools/perf/tests/parse-metric.c
+++ b/tools/perf/tests/parse-metric.c
@@ -69,6 +69,10 @@ static struct pmu_event pme_test[] = {
.metric_expr = "1/m3",
.metric_name = "M3",
},
+{
+ .metric_expr = "64 * l1d.replacement / 1000000000 / duration_time",
+ .metric_name = "L1D_Cache_Fill_BW",
+},
{
.name = NULL,
}
@@ -107,6 +111,8 @@ static void load_runtime_stat(struct runtime_stat *st, struct evlist *evlist,
evlist__for_each_entry(evlist, evsel) {
count = find_value(evsel->name, vals);
perf_stat__update_shadow_stats(evsel, count, 0, st);
+ if (!strcmp(evsel->name, "duration_time"))
+ update_stats(&walltime_nsecs_stats, count);
}
}
@@ -321,6 +327,23 @@ static int test_recursion_fail(void)
return 0;
}
+static int test_memory_bandwidth(void)
+{
+ double ratio;
+ struct value vals[] = {
+ { .event = "l1d.replacement", .val = 4000000 },
+ { .event = "duration_time", .val = 200000000 },
+ { .event = NULL, },
+ };
+
+ TEST_ASSERT_VAL("failed to compute metric",
+ compute_metric("L1D_Cache_Fill_BW", vals, &ratio) == 0);
+ TEST_ASSERT_VAL("L1D_Cache_Fill_BW, wrong ratio",
+ 1.28 == ratio);
+
+ return 0;
+}
+
static int test_metric_group(void)
{
double ratio1, ratio2;
@@ -353,5 +376,6 @@ int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unu
TEST_ASSERT_VAL("DCache_L2 failed", test_dcache_l2() == 0);
TEST_ASSERT_VAL("recursion fail failed", test_recursion_fail() == 0);
TEST_ASSERT_VAL("test metric group", test_metric_group() == 0);
+ TEST_ASSERT_VAL("Memory bandwidth", test_memory_bandwidth() == 0);
return 0;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf test: Add parse-metric memory bandwidth testcase
2021-01-25 12:47 [PATCH] perf test: Add parse-metric memory bandwidth testcase John Garry
@ 2021-02-03 4:24 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2021-02-03 4:24 UTC (permalink / raw)
To: John Garry
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Kajol Jain, linux-kernel, linuxarm
Hello,
On Mon, Jan 25, 2021 at 9:52 PM John Garry <john.garry@huawei.com> wrote:
>
> Event duration_time in a metric expression requires special handling.
>
> Improve test coverage by including a metric whose expression includes
> duration_time. The actual metric is a copied from the L1D_Cache_Fill_BW
> metric on my broadwell machine.
>
> Signed-off-by: John Garry <john.garry@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> Based on acme perf/core + "perf metricgroup: Fix for metrics containing duration_time"
>
> diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c
> index ce7be37f0d88..6dc1db1626ad 100644
> --- a/tools/perf/tests/parse-metric.c
> +++ b/tools/perf/tests/parse-metric.c
> @@ -69,6 +69,10 @@ static struct pmu_event pme_test[] = {
> .metric_expr = "1/m3",
> .metric_name = "M3",
> },
> +{
> + .metric_expr = "64 * l1d.replacement / 1000000000 / duration_time",
> + .metric_name = "L1D_Cache_Fill_BW",
> +},
> {
> .name = NULL,
> }
> @@ -107,6 +111,8 @@ static void load_runtime_stat(struct runtime_stat *st, struct evlist *evlist,
> evlist__for_each_entry(evlist, evsel) {
> count = find_value(evsel->name, vals);
> perf_stat__update_shadow_stats(evsel, count, 0, st);
> + if (!strcmp(evsel->name, "duration_time"))
> + update_stats(&walltime_nsecs_stats, count);
> }
> }
>
> @@ -321,6 +327,23 @@ static int test_recursion_fail(void)
> return 0;
> }
>
> +static int test_memory_bandwidth(void)
> +{
> + double ratio;
> + struct value vals[] = {
> + { .event = "l1d.replacement", .val = 4000000 },
> + { .event = "duration_time", .val = 200000000 },
> + { .event = NULL, },
> + };
> +
> + TEST_ASSERT_VAL("failed to compute metric",
> + compute_metric("L1D_Cache_Fill_BW", vals, &ratio) == 0);
> + TEST_ASSERT_VAL("L1D_Cache_Fill_BW, wrong ratio",
> + 1.28 == ratio);
> +
> + return 0;
> +}
> +
> static int test_metric_group(void)
> {
> double ratio1, ratio2;
> @@ -353,5 +376,6 @@ int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unu
> TEST_ASSERT_VAL("DCache_L2 failed", test_dcache_l2() == 0);
> TEST_ASSERT_VAL("recursion fail failed", test_recursion_fail() == 0);
> TEST_ASSERT_VAL("test metric group", test_metric_group() == 0);
> + TEST_ASSERT_VAL("Memory bandwidth", test_memory_bandwidth() == 0);
> return 0;
> }
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-03 4:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 12:47 [PATCH] perf test: Add parse-metric memory bandwidth testcase John Garry
2021-02-03 4:24 ` Namhyung Kim
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.