@@ -158,6 +158,7 @@ struct perf_sched_map {
158
158
const char * color_cpus_str ;
159
159
const char * task_name ;
160
160
struct strlist * task_names ;
161
+ bool fuzzy ;
161
162
struct perf_cpu_map * cpus ;
162
163
const char * cpus_str ;
163
164
};
@@ -1541,12 +1542,16 @@ map__findnew_thread(struct perf_sched *sched, struct machine *machine, pid_t pid
1541
1542
return thread ;
1542
1543
}
1543
1544
1544
- static bool sched_match_task (const char * comm_str , struct strlist * task_names )
1545
+ static bool sched_match_task (struct perf_sched * sched , const char * comm_str )
1545
1546
{
1547
+ bool fuzzy_match = sched -> map .fuzzy ;
1548
+ struct strlist * task_names = sched -> map .task_names ;
1546
1549
struct str_node * node ;
1547
1550
1548
1551
strlist__for_each_entry (node , task_names ) {
1549
- if (strcmp (comm_str , node -> s ) == 0 )
1552
+ bool match_found = fuzzy_match ? !!strstr (comm_str , node -> s ) :
1553
+ !strcmp (comm_str , node -> s );
1554
+ if (match_found )
1550
1555
return true;
1551
1556
}
1552
1557
@@ -1622,7 +1627,6 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
1622
1627
const char * color = PERF_COLOR_NORMAL ;
1623
1628
char stimestamp [32 ];
1624
1629
const char * str ;
1625
- struct strlist * task_names = sched -> map .task_names ;
1626
1630
1627
1631
BUG_ON (this_cpu .cpu >= MAX_CPUS || this_cpu .cpu < 0 );
1628
1632
@@ -1674,7 +1678,7 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
1674
1678
*/
1675
1679
tr -> shortname [0 ] = '.' ;
1676
1680
tr -> shortname [1 ] = ' ' ;
1677
- } else if (!sched -> map .task_name || sched_match_task (str , task_names )) {
1681
+ } else if (!sched -> map .task_name || sched_match_task (sched , str )) {
1678
1682
tr -> shortname [0 ] = sched -> next_shortname1 ;
1679
1683
tr -> shortname [1 ] = sched -> next_shortname2 ;
1680
1684
@@ -1703,15 +1707,15 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
1703
1707
* Check which of sched_in and sched_out matches the passed --task-name
1704
1708
* arguments and call the corresponding print_sched_map.
1705
1709
*/
1706
- if (sched -> map .task_name && !sched_match_task (str , task_names )) {
1707
- if (!sched_match_task (thread__comm_str (sched_out ), task_names ))
1710
+ if (sched -> map .task_name && !sched_match_task (sched , str )) {
1711
+ if (!sched_match_task (sched , thread__comm_str (sched_out )))
1708
1712
goto out ;
1709
1713
else
1710
1714
goto sched_out ;
1711
1715
1712
1716
} else {
1713
1717
str = thread__comm_str (sched_out );
1714
- if (!(sched -> map .task_name && !sched_match_task (str , task_names )))
1718
+ if (!(sched -> map .task_name && !sched_match_task (sched , str )))
1715
1719
proceed = 1 ;
1716
1720
}
1717
1721
@@ -3655,6 +3659,8 @@ int cmd_sched(int argc, const char **argv)
3655
3659
"display given CPUs in map" ),
3656
3660
OPT_STRING (0 , "task-name" , & sched .map .task_name , "task" ,
3657
3661
"map output only for the given task name(s)." ),
3662
+ OPT_BOOLEAN (0 , "fuzzy-name" , & sched .map .fuzzy ,
3663
+ "given command name can be partially matched (fuzzy matching)" ),
3658
3664
OPT_PARENT (sched_options )
3659
3665
};
3660
3666
const struct option timehist_options [] = {
0 commit comments