diff options
-rw-r--r-- | tools/perf/builtin-record.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 30b83def03d4..de76008fbaa2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -35,6 +35,7 @@ static const char *output_name = "perf.data"; | |||
35 | static int group = 0; | 35 | static int group = 0; |
36 | static unsigned int realtime_prio = 0; | 36 | static unsigned int realtime_prio = 0; |
37 | static int system_wide = 0; | 37 | static int system_wide = 0; |
38 | static int profile_cpu = -1; | ||
38 | static pid_t target_pid = -1; | 39 | static pid_t target_pid = -1; |
39 | static int inherit = 1; | 40 | static int inherit = 1; |
40 | static int force = 0; | 41 | static int force = 0; |
@@ -431,6 +432,8 @@ try_again: | |||
431 | 432 | ||
432 | if (err == EPERM) | 433 | if (err == EPERM) |
433 | die("Permission error - are you root?\n"); | 434 | die("Permission error - are you root?\n"); |
435 | else if (err == ENODEV && profile_cpu != -1) | ||
436 | die("No such device - did you specify an out-of-range profile CPU?\n"); | ||
434 | 437 | ||
435 | /* | 438 | /* |
436 | * If it's cycles then fall back to hrtimer | 439 | * If it's cycles then fall back to hrtimer |
@@ -564,9 +567,15 @@ static int __cmd_record(int argc, const char **argv) | |||
564 | if (pid == -1) | 567 | if (pid == -1) |
565 | pid = getpid(); | 568 | pid = getpid(); |
566 | 569 | ||
567 | open_counters(-1, pid); | 570 | open_counters(profile_cpu, pid); |
568 | } else for (i = 0; i < nr_cpus; i++) | 571 | } else { |
569 | open_counters(i, target_pid); | 572 | if (profile_cpu != -1) { |
573 | open_counters(profile_cpu, target_pid); | ||
574 | } else { | ||
575 | for (i = 0; i < nr_cpus; i++) | ||
576 | open_counters(i, target_pid); | ||
577 | } | ||
578 | } | ||
570 | 579 | ||
571 | if (file_new) | 580 | if (file_new) |
572 | perf_header__write(header, output); | 581 | perf_header__write(header, output); |
@@ -645,6 +654,8 @@ static const struct option options[] = { | |||
645 | "system-wide collection from all CPUs"), | 654 | "system-wide collection from all CPUs"), |
646 | OPT_BOOLEAN('A', "append", &append_file, | 655 | OPT_BOOLEAN('A', "append", &append_file, |
647 | "append to the output file to do incremental profiling"), | 656 | "append to the output file to do incremental profiling"), |
657 | OPT_INTEGER('C', "profile_cpu", &profile_cpu, | ||
658 | "CPU to profile on"), | ||
648 | OPT_BOOLEAN('f', "force", &force, | 659 | OPT_BOOLEAN('f', "force", &force, |
649 | "overwrite existing data file"), | 660 | "overwrite existing data file"), |
650 | OPT_LONG('c', "count", &default_interval, | 661 | OPT_LONG('c', "count", &default_interval, |