@@ -157,6 +157,7 @@ struct perf_sched_map {
157
157
struct perf_cpu_map * color_cpus ;
158
158
const char * color_cpus_str ;
159
159
const char * task_name ;
160
+ struct strlist * task_names ;
160
161
struct perf_cpu_map * cpus ;
161
162
const char * cpus_str ;
162
163
};
@@ -1540,6 +1541,18 @@ map__findnew_thread(struct perf_sched *sched, struct machine *machine, pid_t pid
1540
1541
return thread ;
1541
1542
}
1542
1543
1544
+ static bool sched_match_task (const char * comm_str , struct strlist * task_names )
1545
+ {
1546
+ struct str_node * node ;
1547
+
1548
+ strlist__for_each_entry (node , task_names ) {
1549
+ if (strcmp (comm_str , node -> s ) == 0 )
1550
+ return true;
1551
+ }
1552
+
1553
+ return false;
1554
+ }
1555
+
1543
1556
static void print_sched_map (struct perf_sched * sched , struct perf_cpu this_cpu , int cpus_nr ,
1544
1557
const char * color , bool sched_out )
1545
1558
{
@@ -1609,6 +1622,7 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
1609
1622
const char * color = PERF_COLOR_NORMAL ;
1610
1623
char stimestamp [32 ];
1611
1624
const char * str ;
1625
+ struct strlist * task_names = sched -> map .task_names ;
1612
1626
1613
1627
BUG_ON (this_cpu .cpu >= MAX_CPUS || this_cpu .cpu < 0 );
1614
1628
@@ -1660,7 +1674,7 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
1660
1674
*/
1661
1675
tr -> shortname [0 ] = '.' ;
1662
1676
tr -> shortname [1 ] = ' ' ;
1663
- } else if (!sched -> map .task_name || ! strcmp (str , sched -> map . task_name )) {
1677
+ } else if (!sched -> map .task_name || sched_match_task (str , task_names )) {
1664
1678
tr -> shortname [0 ] = sched -> next_shortname1 ;
1665
1679
tr -> shortname [1 ] = sched -> next_shortname2 ;
1666
1680
@@ -1689,15 +1703,15 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
1689
1703
* Check which of sched_in and sched_out matches the passed --task-name
1690
1704
* arguments and call the corresponding print_sched_map.
1691
1705
*/
1692
- if (sched -> map .task_name && strcmp (str , sched -> map . task_name )) {
1693
- if (strcmp (thread__comm_str (sched_out ), sched -> map . task_name ))
1706
+ if (sched -> map .task_name && ! sched_match_task (str , task_names )) {
1707
+ if (! sched_match_task (thread__comm_str (sched_out ), task_names ))
1694
1708
goto out ;
1695
1709
else
1696
1710
goto sched_out ;
1697
1711
1698
1712
} else {
1699
1713
str = thread__comm_str (sched_out );
1700
- if (!(sched -> map .task_name && strcmp (str , sched -> map . task_name )))
1714
+ if (!(sched -> map .task_name && ! sched_match_task (str , task_names )))
1701
1715
proceed = 1 ;
1702
1716
}
1703
1717
@@ -3640,7 +3654,7 @@ int cmd_sched(int argc, const char **argv)
3640
3654
OPT_STRING (0 , "cpus" , & sched .map .cpus_str , "cpus" ,
3641
3655
"display given CPUs in map" ),
3642
3656
OPT_STRING (0 , "task-name" , & sched .map .task_name , "task" ,
3643
- "map output only for the given task name" ),
3657
+ "map output only for the given task name(s). " ),
3644
3658
OPT_PARENT (sched_options )
3645
3659
};
3646
3660
const struct option timehist_options [] = {
@@ -3739,6 +3753,14 @@ int cmd_sched(int argc, const char **argv)
3739
3753
argc = parse_options (argc , argv , map_options , map_usage , 0 );
3740
3754
if (argc )
3741
3755
usage_with_options (map_usage , map_options );
3756
+
3757
+ if (sched .map .task_name ) {
3758
+ sched .map .task_names = strlist__new (sched .map .task_name , NULL );
3759
+ if (sched .map .task_names == NULL ) {
3760
+ fprintf (stderr , "Failed to parse task names\n" );
3761
+ return -1 ;
3762
+ }
3763
+ }
3742
3764
}
3743
3765
sched .tp_handler = & map_ops ;
3744
3766
setup_sorting (& sched , latency_options , latency_usage );
0 commit comments