diff options
| author | Li Zefan <lizf@cn.fujitsu.com> | 2009-10-14 23:22:07 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2009-10-15 05:35:23 -0400 |
| commit | c171b552a7d316c7e1c3ad6f70a30178dd53e14c (patch) | |
| tree | 99755963367839f3232565acd0ff1680037126fa /tools/perf/builtin-record.c | |
| parent | 6fb2915df7f0747d9044da9dbff5b46dc2e20830 (diff) | |
perf trace: Add filter Suppport
Add a new option "--filter <filter_str>" to perf record, and
it should be right after "-e trace_point":
#./perf record -R -f -e irq:irq_handler_entry --filter irq==18
^C
# ./perf trace
perf-4303 ... irq_handler_entry: irq=18 handler=eth0
init-0 ... irq_handler_entry: irq=18 handler=eth0
init-0 ... irq_handler_entry: irq=18 handler=eth0
init-0 ... irq_handler_entry: irq=18 handler=eth0
init-0 ... irq_handler_entry: irq=18 handler=eth0
See Documentation/trace/events.txt for the syntax of filter
expressions.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4AD6955F.90602@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-record.c')
| -rw-r--r-- | tools/perf/builtin-record.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4e3a374e7aa7..8b2c860c49a2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -374,9 +374,11 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n | |||
| 374 | 374 | ||
| 375 | static void create_counter(int counter, int cpu, pid_t pid) | 375 | static void create_counter(int counter, int cpu, pid_t pid) |
| 376 | { | 376 | { |
| 377 | char *filter = filters[counter]; | ||
| 377 | struct perf_event_attr *attr = attrs + counter; | 378 | struct perf_event_attr *attr = attrs + counter; |
| 378 | struct perf_header_attr *h_attr; | 379 | struct perf_header_attr *h_attr; |
| 379 | int track = !counter; /* only the first counter needs these */ | 380 | int track = !counter; /* only the first counter needs these */ |
| 381 | int ret; | ||
| 380 | struct { | 382 | struct { |
| 381 | u64 count; | 383 | u64 count; |
| 382 | u64 time_enabled; | 384 | u64 time_enabled; |
| @@ -479,7 +481,6 @@ try_again: | |||
| 479 | multiplex_fd = fd[nr_cpu][counter]; | 481 | multiplex_fd = fd[nr_cpu][counter]; |
| 480 | 482 | ||
| 481 | if (multiplex && fd[nr_cpu][counter] != multiplex_fd) { | 483 | if (multiplex && fd[nr_cpu][counter] != multiplex_fd) { |
| 482 | int ret; | ||
| 483 | 484 | ||
| 484 | ret = ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_SET_OUTPUT, multiplex_fd); | 485 | ret = ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_SET_OUTPUT, multiplex_fd); |
| 485 | assert(ret != -1); | 486 | assert(ret != -1); |
| @@ -499,6 +500,16 @@ try_again: | |||
| 499 | } | 500 | } |
| 500 | } | 501 | } |
| 501 | 502 | ||
| 503 | if (filter != NULL) { | ||
| 504 | ret = ioctl(fd[nr_cpu][counter], | ||
| 505 | PERF_EVENT_IOC_SET_FILTER, filter); | ||
| 506 | if (ret) { | ||
| 507 | error("failed to set filter with %d (%s)\n", errno, | ||
| 508 | strerror(errno)); | ||
| 509 | exit(-1); | ||
| 510 | } | ||
| 511 | } | ||
| 512 | |||
| 502 | ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_ENABLE); | 513 | ioctl(fd[nr_cpu][counter], PERF_EVENT_IOC_ENABLE); |
| 503 | } | 514 | } |
| 504 | 515 | ||
| @@ -676,6 +687,8 @@ static const struct option options[] = { | |||
| 676 | OPT_CALLBACK('e', "event", NULL, "event", | 687 | OPT_CALLBACK('e', "event", NULL, "event", |
| 677 | "event selector. use 'perf list' to list available events", | 688 | "event selector. use 'perf list' to list available events", |
| 678 | parse_events), | 689 | parse_events), |
| 690 | OPT_CALLBACK(0, "filter", NULL, "filter", | ||
| 691 | "event filter", parse_filter), | ||
| 679 | OPT_INTEGER('p', "pid", &target_pid, | 692 | OPT_INTEGER('p', "pid", &target_pid, |
| 680 | "record events on existing pid"), | 693 | "record events on existing pid"), |
| 681 | OPT_INTEGER('r', "realtime", &realtime_prio, | 694 | OPT_INTEGER('r', "realtime", &realtime_prio, |
