perf script: Add comm filtering option
PATCH v2 1/1 perf script: Add comm filtering option
Allows collecting events system wide and then pulling out events for a specific task name(s). e.g,
perf script -c gnome-shell,gnome-terminal
Applies on top of:
https://lkml.org/lkml/2011/11/13/74
v1->v2
- use comm_list from symbol_conf
Signed-off-by David Ahern <[email protected]>
--- tools/perf/builtin-script.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
tools/perf/builtin-script.c +12 -0
@@ -440,6 +440,7 @@ static int process_sample_event(union perf_event *event, struct perf_session *session) {struct thread *thread =perf_session__findnew (session, event->ip.pid); +struct addr_location al;if (thread ==NULL ) { pr_debug("problem processing %d event, skipping it.\n",
@@ -458,6 +459,15 @@ static int process_sample_event(union perf_event *event,return 0 ; } +if (perf_event__preprocess_sample (event, session, &al, sample,0 ) <0 ) { +pr_err ("problem processing %d event, skipping it.\n" , + event->header.type); +return -1 ; + } + +if (al.filtered) +return 0 ; +if (cpu_list && !test_bit (sample->cpu, cpu_bitmap))return 0 ;
@@ -1084,6 +1094,8 @@ static const struct option options[] = { "comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr", parse_output_fields),OPT_STRING ('C' ,"cpu" , &cpu_list,"cpu" ,"list of cpus to profile" ), +OPT_STRING ('c' ,"comms" , &symbol_conf.comm_list_str,"comm[,comm...]" , +"only display events for these comms" ),OPT_BOOLEAN ('I' ,"show-info" , &show_full_info,"display extended information from perf.data file" ),OPT_END ()
Signature · 1 line
1.7.7.1