Skip to content

Commit d844780

Browse files
John Garryacmel
authored andcommitted
perf jevents: Support test events folder
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>
1 parent c52db67 commit d844780

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎tools/perf/pmu-events/jevents.c‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,19 @@ static void print_mapping_table_suffix(FILE *outfp)
771771
fprintf(outfp, "};\n");
772772
}
773773

774+
static void print_mapping_test_table(FILE *outfp)
775+
{
776+
/*
777+
* Print the terminating, NULL entry.
778+
*/
779+
fprintf(outfp, "{\n");
780+
fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
781+
fprintf(outfp, "\t.version = \"v1\",\n");
782+
fprintf(outfp, "\t.type = \"core\",\n");
783+
fprintf(outfp, "\t.table = pme_test_cpu,\n");
784+
fprintf(outfp, "},\n");
785+
}
786+
774787
static int process_mapfile(FILE *outfp, char *fpath)
775788
{
776789
int n = 16384;
@@ -848,6 +861,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
848861
}
849862

850863
out:
864+
print_mapping_test_table(outfp);
851865
print_mapping_table_suffix(outfp);
852866
fclose(mapfp);
853867
free(line);
@@ -1168,6 +1182,22 @@ int main(int argc, char *argv[])
11681182
goto empty_map;
11691183
}
11701184

1185+
sprintf(ldirname, "%s/test", start_dirname);
1186+
1187+
rc = nftw(ldirname, process_one_file, maxfds, 0);
1188+
if (rc && verbose) {
1189+
pr_info("%s: Error walking file tree %s rc=%d for test\n",
1190+
prog, ldirname, rc);
1191+
goto empty_map;
1192+
} else if (rc < 0) {
1193+
/* Make build fail */
1194+
free_arch_std_events();
1195+
ret = 1;
1196+
goto out_free_mapfile;
1197+
} else if (rc) {
1198+
goto empty_map;
1199+
}
1200+
11711201
if (close_table)
11721202
print_events_table_suffix(eventsfp);
11731203

0 commit comments

Comments
 (0)