@@ -741,9 +741,11 @@ static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
741
741
}
742
742
743
743
struct pmu_add_cpu_aliases_map_data {
744
+ /* List being added to. */
744
745
struct list_head * head ;
745
- const char * name ;
746
- const char * cpu_name ;
746
+ /* If a pmu_event lacks a given PMU the default used. */
747
+ char * default_pmu_name ;
748
+ /* The PMU that we're searching for events for. */
747
749
struct perf_pmu * pmu ;
748
750
};
749
751
@@ -752,37 +754,32 @@ static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
752
754
void * vdata )
753
755
{
754
756
struct pmu_add_cpu_aliases_map_data * data = vdata ;
755
- const char * pname = pe -> pmu ? pe -> pmu : data -> cpu_name ;
757
+ const char * pname = pe -> pmu ?: data -> default_pmu_name ;
756
758
757
- if (data -> pmu -> is_uncore && pmu_uncore_alias_match (pname , data -> name ))
758
- goto new_alias ;
759
-
760
- if (strcmp (pname , data -> name ))
761
- return 0 ;
762
-
763
- new_alias :
764
- /* need type casts to override 'const' */
765
- __perf_pmu__new_alias (data -> head , -1 , (char * )pe -> name , (char * )pe -> desc ,
766
- (char * )pe -> event , pe );
759
+ if (!strcmp (pname , data -> pmu -> name ) ||
760
+ (data -> pmu -> is_uncore && pmu_uncore_alias_match (pname , data -> pmu -> name ))) {
761
+ /* need type casts to override 'const' */
762
+ __perf_pmu__new_alias (data -> head , -1 , (char * )pe -> name , (char * )pe -> desc ,
763
+ (char * )pe -> event , pe );
764
+ }
767
765
return 0 ;
768
766
}
769
767
770
768
/*
771
- * From the pmu_events_map, find the table of PMU events that corresponds
772
- * to the current running CPU. Then, add all PMU events from that table
773
- * as aliases.
769
+ * From the pmu_events_table, find the events that correspond to the given
770
+ * PMU and add them to the list 'head'.
774
771
*/
775
772
void pmu_add_cpu_aliases_table (struct list_head * head , struct perf_pmu * pmu ,
776
- const struct pmu_events_table * table )
773
+ const struct pmu_events_table * table )
777
774
{
778
775
struct pmu_add_cpu_aliases_map_data data = {
779
776
.head = head ,
780
- .name = pmu -> name ,
781
- .cpu_name = is_sysfs_pmu_core (pmu -> name ) ? pmu -> name : "cpu" ,
777
+ .default_pmu_name = perf_pmus__default_pmu_name (),
782
778
.pmu = pmu ,
783
779
};
784
780
785
781
pmu_events_table_for_each_event (table , pmu_add_cpu_aliases_map_callback , & data );
782
+ free (data .default_pmu_name );
786
783
}
787
784
788
785
static void pmu_add_cpu_aliases (struct list_head * head , struct perf_pmu * pmu )
0 commit comments