aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-08-12 05:18:01 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-12 08:10:51 -0400
commit0a5ac84650fb7a7f226814103d95724e34b012ae (patch)
tree8fb0ec43e619a8aca91791d113663e68f220d30a
parent1340e6bbaff7ff7f6f75eb4a5c34933efce84a84 (diff)
perf record: Add missing -C option support for specifying profile cpu
perf top supports a -C for setting the profile CPU, but perf record does not. This adds the same option for perf record, allowing the user to specify a specific target profile CPU. Signed-off-by: Jens Axboe <jens.axboe@oracle.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20090812091801.GC12579@kernel.dk> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/builtin-record.c17
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";
35static int group = 0; 35static int group = 0;
36static unsigned int realtime_prio = 0; 36static unsigned int realtime_prio = 0;
37static int system_wide = 0; 37static int system_wide = 0;
38static int profile_cpu = -1;
38static pid_t target_pid = -1; 39static pid_t target_pid = -1;
39static int inherit = 1; 40static int inherit = 1;
40static int force = 0; 41static 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,