Skip to content

Commit e7984b7

Browse files
dsahernacmel
authored andcommitted
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 v2->v3 - update Documentation v1->v2 - use comm_list from symbol_conf Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1321894972-24246-1-git-send-email-dsahern@gmail.com Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent c8e6672 commit e7984b7

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎tools/perf/Documentation/perf-script.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ OPTIONS
188188
CPUs are specified with -: 0-2. Default is to report samples on all
189189
CPUs.
190190

191+
-c::
192+
--comms=::
193+
Only display events for these comms. CSV that understands
194+
file://filename entries.
195+
191196
-I::
192197
--show-info::
193198
Display extended information about the perf.data file. This adds

‎tools/perf/builtin-script.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ static int process_sample_event(struct perf_tool *tool __used,
441441
struct perf_evsel *evsel,
442442
struct machine *machine)
443443
{
444+
struct addr_location al;
444445
struct thread *thread = machine__findnew_thread(machine, event->ip.pid);
445446

446447
if (thread == NULL) {
@@ -460,6 +461,15 @@ static int process_sample_event(struct perf_tool *tool __used,
460461
return 0;
461462
}
462463

464+
if (perf_event__preprocess_sample(event, machine, &al, sample, 0) < 0) {
465+
pr_err("problem processing %d event, skipping it.\n",
466+
event->header.type);
467+
return -1;
468+
}
469+
470+
if (al.filtered)
471+
return 0;
472+
463473
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
464474
return 0;
465475

@@ -1086,6 +1096,8 @@ static const struct option options[] = {
10861096
"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",
10871097
parse_output_fields),
10881098
OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
1099+
OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
1100+
"only display events for these comms"),
10891101
OPT_BOOLEAN('I', "show-info", &show_full_info,
10901102
"display extended information from perf.data file"),
10911103
OPT_END()

0 commit comments

Comments
 (0)