@@ -272,13 +272,11 @@ static bool is_same(const char *reference, const char *test)
272
272
return !strcmp (reference , test );
273
273
}
274
274
275
- static const struct pmu_events_map * __test_pmu_get_events_map (void )
275
+ static const struct pmu_event * __test_pmu_get_events_table (void )
276
276
{
277
- const struct pmu_events_map * map ;
278
-
279
- for (map = & pmu_events_map [0 ]; map -> cpuid ; map ++ ) {
277
+ for (const struct pmu_events_map * map = & pmu_events_map [0 ]; map -> cpuid ; map ++ ) {
280
278
if (!strcmp (map -> cpuid , "testcpu" ))
281
- return map ;
279
+ return map -> table ;
282
280
}
283
281
284
282
pr_err ("could not find test events map\n" );
@@ -440,19 +438,18 @@ static int test__pmu_event_table(struct test_suite *test __maybe_unused,
440
438
int subtest __maybe_unused )
441
439
{
442
440
const struct pmu_event * sys_event_tables = find_sys_events_table ("pme_test_soc_sys" );
443
- const struct pmu_events_map * map = __test_pmu_get_events_map ();
444
- const struct pmu_event * table ;
441
+ const struct pmu_event * table = __test_pmu_get_events_table ();
445
442
int map_events = 0 , expected_events ;
446
443
447
444
/* ignore 3x sentinels */
448
445
expected_events = ARRAY_SIZE (core_events ) +
449
446
ARRAY_SIZE (uncore_events ) +
450
447
ARRAY_SIZE (sys_events ) - 3 ;
451
448
452
- if (!map || !sys_event_tables )
449
+ if (!table || !sys_event_tables )
453
450
return -1 ;
454
451
455
- for (table = map -> table ; table -> name ; table ++ ) {
452
+ for (; table -> name ; table ++ ) {
456
453
struct perf_pmu_test_event const * * test_event_table ;
457
454
bool found = false;
458
455
@@ -537,10 +534,10 @@ static int __test_core_pmu_event_aliases(char *pmu_name, int *count)
537
534
struct perf_pmu * pmu ;
538
535
LIST_HEAD (aliases );
539
536
int res = 0 ;
540
- const struct pmu_events_map * map = __test_pmu_get_events_map ();
537
+ const struct pmu_event * table = __test_pmu_get_events_table ();
541
538
struct perf_pmu_alias * a , * tmp ;
542
539
543
- if (!map )
540
+ if (!table )
544
541
return -1 ;
545
542
546
543
test_event_table = & core_events [0 ];
@@ -551,7 +548,7 @@ static int __test_core_pmu_event_aliases(char *pmu_name, int *count)
551
548
552
549
pmu -> name = pmu_name ;
553
550
554
- pmu_add_cpu_aliases_map (& aliases , pmu , map );
551
+ pmu_add_cpu_aliases_table (& aliases , pmu , table );
555
552
556
553
for (; * test_event_table ; test_event_table ++ ) {
557
554
struct perf_pmu_test_event const * test_event = * test_event_table ;
@@ -590,14 +587,14 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
590
587
struct perf_pmu * pmu = & test_pmu -> pmu ;
591
588
const char * pmu_name = pmu -> name ;
592
589
struct perf_pmu_alias * a , * tmp , * alias ;
593
- const struct pmu_events_map * map ;
590
+ const struct pmu_event * events_table ;
594
591
LIST_HEAD (aliases );
595
592
int res = 0 ;
596
593
597
- map = __test_pmu_get_events_map ();
598
- if (!map )
594
+ events_table = __test_pmu_get_events_table ();
595
+ if (!events_table )
599
596
return -1 ;
600
- pmu_add_cpu_aliases_map (& aliases , pmu , map );
597
+ pmu_add_cpu_aliases_table (& aliases , pmu , events_table );
601
598
pmu_add_sys_aliases (& aliases , pmu );
602
599
603
600
/* Count how many aliases we generated */
@@ -848,13 +845,9 @@ static int check_parse_fake(const char *id)
848
845
return ret ;
849
846
}
850
847
851
- static void expr_failure (const char * msg ,
852
- const struct pmu_events_map * map ,
853
- const struct pmu_event * pe )
848
+ static void expr_failure (const char * msg , const struct pmu_event * pe )
854
849
{
855
- pr_debug ("%s for map %s %s\n" , msg , map -> arch , map -> cpuid );
856
- pr_debug ("On metric %s\n" , pe -> metric_name );
857
- pr_debug ("On expression %s\n" , pe -> metric_expr );
850
+ pr_debug ("%s\nOn metric %s\nOn expression %s\n" , msg , pe -> metric_name , pe -> metric_expr );
858
851
}
859
852
860
853
struct metric {
@@ -864,7 +857,7 @@ struct metric {
864
857
865
858
static int resolve_metric_simple (struct expr_parse_ctx * pctx ,
866
859
struct list_head * compound_list ,
867
- const struct pmu_events_map * map ,
860
+ const struct pmu_event * map ,
868
861
const char * metric_name )
869
862
{
870
863
struct hashmap_entry * cur , * cur_tmp ;
@@ -925,8 +918,7 @@ static int resolve_metric_simple(struct expr_parse_ctx *pctx,
925
918
static int test__parsing (struct test_suite * test __maybe_unused ,
926
919
int subtest __maybe_unused )
927
920
{
928
- const struct pmu_events_map * cpus_map = pmu_events_map__find ();
929
- const struct pmu_events_map * map ;
921
+ const struct pmu_event * cpus_table = pmu_events_table__find ();
930
922
const struct pmu_event * pe ;
931
923
int i , j , k ;
932
924
int ret = 0 ;
@@ -940,7 +932,8 @@ static int test__parsing(struct test_suite *test __maybe_unused,
940
932
}
941
933
i = 0 ;
942
934
for (;;) {
943
- map = & pmu_events_map [i ++ ];
935
+ const struct pmu_events_map * map = & pmu_events_map [i ++ ];
936
+
944
937
if (!map -> table )
945
938
break ;
946
939
j = 0 ;
@@ -957,14 +950,14 @@ static int test__parsing(struct test_suite *test __maybe_unused,
957
950
continue ;
958
951
expr__ctx_clear (ctx );
959
952
if (expr__find_ids (pe -> metric_expr , NULL , ctx ) < 0 ) {
960
- expr_failure ("Parse find ids failed" , map , pe );
953
+ expr_failure ("Parse find ids failed" , pe );
961
954
ret ++ ;
962
955
continue ;
963
956
}
964
957
965
- if (resolve_metric_simple (ctx , & compound_list , map ,
958
+ if (resolve_metric_simple (ctx , & compound_list , map -> table ,
966
959
pe -> metric_name )) {
967
- expr_failure ("Could not resolve metrics" , map , pe );
960
+ expr_failure ("Could not resolve metrics" , pe );
968
961
ret ++ ;
969
962
goto exit ; /* Don't tolerate errors due to severity */
970
963
}
@@ -979,7 +972,7 @@ static int test__parsing(struct test_suite *test __maybe_unused,
979
972
expr__add_id_val (ctx , strdup (cur -> key ), k ++ );
980
973
981
974
hashmap__for_each_entry (ctx -> ids , cur , bkt ) {
982
- if (check_parse_cpu (cur -> key , map == cpus_map ,
975
+ if (check_parse_cpu (cur -> key , map -> table == cpus_table ,
983
976
pe ))
984
977
ret ++ ;
985
978
}
@@ -999,7 +992,7 @@ static int test__parsing(struct test_suite *test __maybe_unused,
999
992
hashmap__for_each_entry (ctx -> ids , cur , bkt )
1000
993
expr__add_id_val (ctx , strdup (cur -> key ), k -- );
1001
994
if (expr__parse (& result , ctx , pe -> metric_expr )) {
1002
- expr_failure ("Parse failed" , map , pe );
995
+ expr_failure ("Parse failed" , pe );
1003
996
ret ++ ;
1004
997
}
1005
998
}
@@ -1088,8 +1081,6 @@ static int metric_parse_fake(const char *str)
1088
1081
static int test__parsing_fake (struct test_suite * test __maybe_unused ,
1089
1082
int subtest __maybe_unused )
1090
1083
{
1091
- const struct pmu_events_map * map ;
1092
- const struct pmu_event * pe ;
1093
1084
unsigned int i , j ;
1094
1085
int err = 0 ;
1095
1086
@@ -1101,12 +1092,14 @@ static int test__parsing_fake(struct test_suite *test __maybe_unused,
1101
1092
1102
1093
i = 0 ;
1103
1094
for (;;) {
1104
- map = & pmu_events_map [i ++ ];
1095
+ const struct pmu_events_map * map = & pmu_events_map [i ++ ];
1096
+
1105
1097
if (!map -> table )
1106
1098
break ;
1107
1099
j = 0 ;
1108
1100
for (;;) {
1109
- pe = & map -> table [j ++ ];
1101
+ const struct pmu_event * pe = & map -> table [j ++ ];
1102
+
1110
1103
if (!pe -> name && !pe -> metric_group && !pe -> metric_name )
1111
1104
break ;
1112
1105
if (!pe -> metric_expr )
0 commit comments