Commit 55f30d68 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf metric: Add cache_miss_cycles to metric parse test

Adding test that compute metric with other metrics in it.

  cache_miss_cycles = metric:dcache_miss_cpi + metric:icache_miss_cycles

Committer notes:

Fixed up initializer to cope with:

  tests/parse-metric.c:242:7: error: missing field 'val' initializer [-Werror,-Wmissing-field-initializers]
                  { 0 },
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200719181320.785305-14-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 98461d9d
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "debug.h" #include "debug.h"
#include "expr.h" #include "expr.h"
#include "stat.h" #include "stat.h"
#include <perf/cpumap.h>
#include <perf/evlist.h>
static struct pmu_event pme_test[] = { static struct pmu_event pme_test[] = {
{ {
...@@ -22,6 +24,18 @@ static struct pmu_event pme_test[] = { ...@@ -22,6 +24,18 @@ static struct pmu_event pme_test[] = {
"( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))", "( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))",
.metric_name = "Frontend_Bound_SMT", .metric_name = "Frontend_Bound_SMT",
}, },
{
.metric_expr = "l1d\\-loads\\-misses / inst_retired.any",
.metric_name = "dcache_miss_cpi",
},
{
.metric_expr = "l1i\\-loads\\-misses / inst_retired.any",
.metric_name = "icache_miss_cycles",
},
{
.metric_expr = "(dcache_miss_cpi + icache_miss_cycles)",
.metric_name = "cache_miss_cycles",
},
}; };
static struct pmu_events_map map = { static struct pmu_events_map map = {
...@@ -162,9 +176,28 @@ static int test_frontend(void) ...@@ -162,9 +176,28 @@ static int test_frontend(void)
return 0; return 0;
} }
static int test_cache_miss_cycles(void)
{
double ratio;
struct value vals[] = {
{ .event = "l1d-loads-misses", .val = 300 },
{ .event = "l1i-loads-misses", .val = 200 },
{ .event = "inst_retired.any", .val = 400 },
{ .event = NULL, },
};
TEST_ASSERT_VAL("failed to compute metric",
compute_metric("cache_miss_cycles", vals, &ratio) == 0);
TEST_ASSERT_VAL("cache_miss_cycles failed, wrong ratio",
ratio == 1.25);
return 0;
}
int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused) int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused)
{ {
TEST_ASSERT_VAL("IPC failed", test_ipc() == 0); TEST_ASSERT_VAL("IPC failed", test_ipc() == 0);
TEST_ASSERT_VAL("frontend failed", test_frontend() == 0); TEST_ASSERT_VAL("frontend failed", test_frontend() == 0);
TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 0);
return 0; return 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