@@ -625,6 +625,39 @@ static int __metricgroup__add_metric(struct list_head *group_list,
625
625
(match_metric(__pe->metric_group, __metric) || \
626
626
match_metric(__pe->metric_name, __metric)))
627
627
628
+ static int add_metric (struct list_head * group_list ,
629
+ struct pmu_event * pe ,
630
+ bool metric_no_group )
631
+ {
632
+ int ret = 0 ;
633
+
634
+ pr_debug ("metric expr %s for %s\n" , pe -> metric_expr , pe -> metric_name );
635
+
636
+ if (!strstr (pe -> metric_expr , "?" )) {
637
+ ret = __metricgroup__add_metric (group_list ,
638
+ pe ,
639
+ metric_no_group ,
640
+ 1 );
641
+ } else {
642
+ int j , count ;
643
+
644
+ count = arch_get_runtimeparam ();
645
+
646
+ /* This loop is added to create multiple
647
+ * events depend on count value and add
648
+ * those events to group_list.
649
+ */
650
+
651
+ for (j = 0 ; j < count && !ret ; j ++ ) {
652
+ ret = __metricgroup__add_metric (
653
+ group_list , pe ,
654
+ metric_no_group , j );
655
+ }
656
+ }
657
+
658
+ return ret ;
659
+ }
660
+
628
661
static int metricgroup__add_metric (const char * metric , bool metric_no_group ,
629
662
struct strbuf * events ,
630
663
struct list_head * group_list ,
@@ -636,34 +669,11 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group,
636
669
bool has_match = false;
637
670
638
671
map_for_each_metric (pe , i , map , metric ) {
639
- pr_debug ("metric expr %s for %s\n" , pe -> metric_expr , pe -> metric_name );
640
672
has_match = true;
641
673
642
- if (!strstr (pe -> metric_expr , "?" )) {
643
- ret = __metricgroup__add_metric (group_list ,
644
- pe ,
645
- metric_no_group ,
646
- 1 );
647
- if (ret )
648
- return ret ;
649
- } else {
650
- int j , count ;
651
-
652
- count = arch_get_runtimeparam ();
653
-
654
- /* This loop is added to create multiple
655
- * events depend on count value and add
656
- * those events to group_list.
657
- */
658
-
659
- for (j = 0 ; j < count ; j ++ ) {
660
- ret = __metricgroup__add_metric (
661
- group_list , pe ,
662
- metric_no_group , j );
663
- if (ret )
664
- return ret ;
665
- }
666
- }
674
+ ret = add_metric (group_list , pe , metric_no_group );
675
+ if (ret )
676
+ return ret ;
667
677
}
668
678
669
679
/* End of pmu events. */
0 commit comments