diff options
author | Stephane Eranian <eranian@google.com> | 2010-05-28 06:00:01 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-05 08:33:01 -0400 |
commit | c45c6ea2e5c57960dc67e00294c2b78e9540c007 (patch) | |
tree | 27c56577862cbb95fb8db4b34cfe99878d5dc9a0 /tools/perf/builtin-record.c | |
parent | 761844b9c68b3c67b085265f92ac0675706cc3b3 (diff) |
perf tools: Add the ability to specify list of cpus to monitor
This patch adds a -C option to stat, record, top to designate a list of CPUs to
monitor. CPUs can be specified as a comma-separated list or ranges, no space
allowed.
Examples:
$ perf record -a -C0-1,4-7 sleep 1
$ perf top -C0-4
$ perf stat -a -C1,2,3,4 sleep 1
With perf record in per-thread mode with inherit mode on, samples are collected
only when the thread runs on the designated CPUs.
The -C option does not turn on system-wide mode automatically.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4bff9496.d345d80a.41fe.7b00@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index dc3435e18bde..f28c4bbd801f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -49,7 +49,6 @@ static int group = 0; | |||
49 | static int realtime_prio = 0; | 49 | static int realtime_prio = 0; |
50 | static bool raw_samples = false; | 50 | static bool raw_samples = false; |
51 | static bool system_wide = false; | 51 | static bool system_wide = false; |
52 | static int profile_cpu = -1; | ||
53 | static pid_t target_pid = -1; | 52 | static pid_t target_pid = -1; |
54 | static pid_t target_tid = -1; | 53 | static pid_t target_tid = -1; |
55 | static pid_t *all_tids = NULL; | 54 | static pid_t *all_tids = NULL; |
@@ -74,6 +73,7 @@ static int file_new = 1; | |||
74 | static off_t post_processing_offset; | 73 | static off_t post_processing_offset; |
75 | 74 | ||
76 | static struct perf_session *session; | 75 | static struct perf_session *session; |
76 | static const char *cpu_list; | ||
77 | 77 | ||
78 | struct mmap_data { | 78 | struct mmap_data { |
79 | int counter; | 79 | int counter; |
@@ -300,7 +300,7 @@ try_again: | |||
300 | die("Permission error - are you root?\n" | 300 | die("Permission error - are you root?\n" |
301 | "\t Consider tweaking" | 301 | "\t Consider tweaking" |
302 | " /proc/sys/kernel/perf_event_paranoid.\n"); | 302 | " /proc/sys/kernel/perf_event_paranoid.\n"); |
303 | else if (err == ENODEV && profile_cpu != -1) { | 303 | else if (err == ENODEV && cpu_list) { |
304 | die("No such device - did you specify" | 304 | die("No such device - did you specify" |
305 | " an out-of-range profile CPU?\n"); | 305 | " an out-of-range profile CPU?\n"); |
306 | } | 306 | } |
@@ -622,10 +622,15 @@ static int __cmd_record(int argc, const char **argv) | |||
622 | close(child_ready_pipe[0]); | 622 | close(child_ready_pipe[0]); |
623 | } | 623 | } |
624 | 624 | ||
625 | if ((!system_wide && no_inherit) || profile_cpu != -1) { | 625 | nr_cpus = read_cpu_map(cpu_list); |
626 | open_counters(profile_cpu); | 626 | if (nr_cpus < 1) { |
627 | perror("failed to collect number of CPUs\n"); | ||
628 | return -1; | ||
629 | } | ||
630 | |||
631 | if (!system_wide && no_inherit && !cpu_list) { | ||
632 | open_counters(-1); | ||
627 | } else { | 633 | } else { |
628 | nr_cpus = read_cpu_map(); | ||
629 | for (i = 0; i < nr_cpus; i++) | 634 | for (i = 0; i < nr_cpus; i++) |
630 | open_counters(cpumap[i]); | 635 | open_counters(cpumap[i]); |
631 | } | 636 | } |
@@ -704,7 +709,7 @@ static int __cmd_record(int argc, const char **argv) | |||
704 | if (perf_guest) | 709 | if (perf_guest) |
705 | perf_session__process_machines(session, event__synthesize_guest_os); | 710 | perf_session__process_machines(session, event__synthesize_guest_os); |
706 | 711 | ||
707 | if (!system_wide && profile_cpu == -1) | 712 | if (!system_wide && cpu_list) |
708 | event__synthesize_thread(target_tid, process_synthesized_event, | 713 | event__synthesize_thread(target_tid, process_synthesized_event, |
709 | session); | 714 | session); |
710 | else | 715 | else |
@@ -794,8 +799,8 @@ static const struct option options[] = { | |||
794 | "system-wide collection from all CPUs"), | 799 | "system-wide collection from all CPUs"), |
795 | OPT_BOOLEAN('A', "append", &append_file, | 800 | OPT_BOOLEAN('A', "append", &append_file, |
796 | "append to the output file to do incremental profiling"), | 801 | "append to the output file to do incremental profiling"), |
797 | OPT_INTEGER('C', "profile_cpu", &profile_cpu, | 802 | OPT_STRING('C', "cpu", &cpu_list, "cpu", |
798 | "CPU to profile on"), | 803 | "list of cpus to monitor"), |
799 | OPT_BOOLEAN('f', "force", &force, | 804 | OPT_BOOLEAN('f', "force", &force, |
800 | "overwrite existing data file (deprecated)"), | 805 | "overwrite existing data file (deprecated)"), |
801 | OPT_U64('c', "count", &user_interval, "event period to sample"), | 806 | OPT_U64('c', "count", &user_interval, "event period to sample"), |
@@ -825,7 +830,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
825 | argc = parse_options(argc, argv, options, record_usage, | 830 | argc = parse_options(argc, argv, options, record_usage, |
826 | PARSE_OPT_STOP_AT_NON_OPTION); | 831 | PARSE_OPT_STOP_AT_NON_OPTION); |
827 | if (!argc && target_pid == -1 && target_tid == -1 && | 832 | if (!argc && target_pid == -1 && target_tid == -1 && |
828 | !system_wide && profile_cpu == -1) | 833 | !system_wide && !cpu_list) |
829 | usage_with_options(record_usage, options); | 834 | usage_with_options(record_usage, options); |
830 | 835 | ||
831 | if (force && append_file) { | 836 | if (force && append_file) { |