170 lines
4.6 KiB
Diff
170 lines
4.6 KiB
Diff
From 37a0ab8d2dd9fc5edd3091d2c5843dd327875398 Mon Sep 17 00:00:00 2001
|
|
From: John Garry <john.garry@huawei.com>
|
|
Date: Tue, 17 Mar 2020 19:02:14 +0800
|
|
Subject: [PATCH 065/201] perf jevents: Support test events folder
|
|
|
|
mainline inclusion
|
|
from mainline-v5.7-rc1
|
|
commit d84478088780acdecfcf50a0e52b71cc4ab7c520
|
|
category: feature
|
|
bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d84478088780acdecfcf50a0e52b71cc4ab7c520
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
With the goal of supporting pmu-events test case, introduce support for
|
|
a test events folder.
|
|
|
|
These test events can be used for testing generation of pmu-event tables
|
|
and alias creation for any arch.
|
|
|
|
When running the pmu-events test case, these test events will be used as
|
|
the platform-agnostic events, so aliases can be created per-PMU and
|
|
validated against known expected values.
|
|
|
|
To support the test events, add a "testcpu" entry in pmu_events_map[].
|
|
The pmu-events test will be able to lookup the events map for "testcpu",
|
|
to verify the generated tables against expected values.
|
|
|
|
The resultant generated pmu-events.c will now look like the following:
|
|
|
|
struct pmu_event pme_ampere_emag[] = {
|
|
{
|
|
.name = "ldrex_spec",
|
|
.event = "event=0x6c",
|
|
.desc = "Exclusive operation spe...",
|
|
.topic = "intrinsic",
|
|
.long_desc = "Exclusive operation ...",
|
|
},
|
|
...
|
|
};
|
|
|
|
struct pmu_event pme_test_cpu[] = {
|
|
{
|
|
.name = "uncore_hisi_ddrc.flux_wcmd",
|
|
.event = "event=0x2",
|
|
.desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
|
|
.topic = "uncore",
|
|
.long_desc = "DDRC write commands",
|
|
.pmu = "hisi_sccl,ddrc",
|
|
},
|
|
{
|
|
.name = "unc_cbo_xsnp_response.miss_eviction",
|
|
.event = "umask=0x81,event=0x22",
|
|
.desc = "Unit: uncore_cbox A cross-core snoop resulted ...",
|
|
.topic = "uncore",
|
|
.long_desc = "A cross-core snoop resulted from L3 ...",
|
|
.pmu = "uncore_cbox",
|
|
},
|
|
{
|
|
.name = "eist_trans",
|
|
.event = "umask=0x0,period=200000,event=0x3a",
|
|
.desc = "Number of Enhanced Intel SpeedStep(R) ...",
|
|
.topic = "other",
|
|
},
|
|
{
|
|
.name = 0,
|
|
},
|
|
};
|
|
|
|
struct pmu_events_map pmu_events_map[] = {
|
|
...
|
|
{
|
|
.cpuid = "0x00000000500f0000",
|
|
.version = "v1",
|
|
.type = "core",
|
|
.table = pme_ampere_emag
|
|
},
|
|
...
|
|
{
|
|
.cpuid = "testcpu",
|
|
.version = "v1",
|
|
.type = "core",
|
|
.table = pme_test_cpu,
|
|
},
|
|
{
|
|
.cpuid = 0,
|
|
.version = 0,
|
|
.type = 0,
|
|
.table = 0,
|
|
},
|
|
};
|
|
|
|
Signed-off-by: John Garry <john.garry@huawei.com>
|
|
Acked-by: Jiri Olsa <jolsa@redhat.com>
|
|
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
|
|
Cc: Andi Kleen <ak@linux.intel.com>
|
|
Cc: James Clark <james.clark@arm.com>
|
|
Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
|
|
Cc: Mark Rutland <mark.rutland@arm.com>
|
|
Cc: Namhyung Kim <namhyung@kernel.org>
|
|
Cc: Peter Zijlstra <peterz@infradead.org>
|
|
Cc: Will Deacon <will@kernel.org>
|
|
Cc: linuxarm@huawei.com
|
|
Link: http://lore.kernel.org/lkml/1584442939-8911-3-git-send-email-john.garry@huawei.com
|
|
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
|
|
---
|
|
tools/perf/pmu-events/jevents.c | 30 ++++++++++++++++++++++++++++++
|
|
1 file changed, 30 insertions(+)
|
|
|
|
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
|
|
index 6bf2237fef2d..1f7d4c53631d 100644
|
|
--- a/tools/perf/pmu-events/jevents.c
|
|
+++ b/tools/perf/pmu-events/jevents.c
|
|
@@ -772,6 +772,19 @@ static void print_mapping_table_suffix(FILE *outfp)
|
|
fprintf(outfp, "};\n");
|
|
}
|
|
|
|
+static void print_mapping_test_table(FILE *outfp)
|
|
+{
|
|
+ /*
|
|
+ * Print the terminating, NULL entry.
|
|
+ */
|
|
+ fprintf(outfp, "{\n");
|
|
+ fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
|
|
+ fprintf(outfp, "\t.version = \"v1\",\n");
|
|
+ fprintf(outfp, "\t.type = \"core\",\n");
|
|
+ fprintf(outfp, "\t.table = pme_test_cpu,\n");
|
|
+ fprintf(outfp, "},\n");
|
|
+}
|
|
+
|
|
static int process_mapfile(FILE *outfp, char *fpath)
|
|
{
|
|
int n = 16384;
|
|
@@ -849,6 +862,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
|
|
}
|
|
|
|
out:
|
|
+ print_mapping_test_table(outfp);
|
|
print_mapping_table_suffix(outfp);
|
|
fclose(mapfp);
|
|
free(line);
|
|
@@ -1169,6 +1183,22 @@ int main(int argc, char *argv[])
|
|
goto empty_map;
|
|
}
|
|
|
|
+ sprintf(ldirname, "%s/test", start_dirname);
|
|
+
|
|
+ rc = nftw(ldirname, process_one_file, maxfds, 0);
|
|
+ if (rc && verbose) {
|
|
+ pr_info("%s: Error walking file tree %s rc=%d for test\n",
|
|
+ prog, ldirname, rc);
|
|
+ goto empty_map;
|
|
+ } else if (rc < 0) {
|
|
+ /* Make build fail */
|
|
+ free_arch_std_events();
|
|
+ ret = 1;
|
|
+ goto out_free_mapfile;
|
|
+ } else if (rc) {
|
|
+ goto empty_map;
|
|
+ }
|
|
+
|
|
if (close_table)
|
|
print_events_table_suffix(eventsfp);
|
|
|
|
--
|
|
2.27.0
|
|
|