aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-06-02 16:59:57 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-02 17:01:02 -0400
commitabaff32a03e26e5d6674cb2a26ad882efe7493a3 (patch)
treeb3fa593c499d50975dbe52d1300dec5972735008
parentcf25c63c609e99bfb9303b68a7a90a56a3a32cea (diff)
perf record: Add --append option
Allow incremental profiling via 'perf record -A' - this will append to an existing perf.data. Also reorder perf record options by utility / likelyhood of usage. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: John Kacur <jkacur@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--Documentation/perf_counter/builtin-record.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/Documentation/perf_counter/builtin-record.c b/Documentation/perf_counter/builtin-record.c
index c2fd04244972..19cba6b5ee9c 100644
--- a/Documentation/perf_counter/builtin-record.c
+++ b/Documentation/perf_counter/builtin-record.c
@@ -1,5 +1,7 @@
1 1/*
2 2 * perf record: Record the profile of a workload (or a CPU, or a PID) into
3 * the perf.data output file - for later analysis via perf report.
4 */
3#include "perf.h" 5#include "perf.h"
4#include "builtin.h" 6#include "builtin.h"
5#include "util/util.h" 7#include "util/util.h"
@@ -28,6 +30,7 @@ static int system_wide = 0;
28static pid_t target_pid = -1; 30static pid_t target_pid = -1;
29static int inherit = 1; 31static int inherit = 1;
30static int force = 0; 32static int force = 0;
33static int append_file = 0;
31 34
32const unsigned int default_count[] = { 35const unsigned int default_count[] = {
33 1000000, 36 1000000,
@@ -385,22 +388,29 @@ static void open_counters(int cpu, pid_t pid)
385static int __cmd_record(int argc, const char **argv) 388static int __cmd_record(int argc, const char **argv)
386{ 389{
387 int i, counter; 390 int i, counter;
391 struct stat st;
388 pid_t pid; 392 pid_t pid;
393 int flags;
389 int ret; 394 int ret;
390 struct stat st;
391 395
392 page_size = sysconf(_SC_PAGE_SIZE); 396 page_size = sysconf(_SC_PAGE_SIZE);
393 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); 397 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
394 assert(nr_cpus <= MAX_NR_CPUS); 398 assert(nr_cpus <= MAX_NR_CPUS);
395 assert(nr_cpus >= 0); 399 assert(nr_cpus >= 0);
396 400
397 if (!stat(output_name, &st) && !force) { 401 if (!stat(output_name, &st) && !force && !append_file) {
398 fprintf(stderr, "Error, output file: %s exists, use -f to overwrite.\n", 402 fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
399 output_name); 403 output_name);
400 exit(-1); 404 exit(-1);
401 } 405 }
402 406
403 output = open(output_name, O_CREAT|O_TRUNC|O_RDWR, S_IRUSR|S_IWUSR); 407 flags = O_CREAT|O_RDWR;
408 if (append_file)
409 flags |= O_APPEND;
410 else
411 flags |= O_TRUNC;
412
413 output = open(output_name, flags, S_IRUSR|S_IWUSR);
404 if (output < 0) { 414 if (output < 0) {
405 perror("failed to create output file"); 415 perror("failed to create output file");
406 exit(-1); 416 exit(-1);
@@ -466,22 +476,24 @@ static char events_help_msg[EVENTS_HELP_MAX];
466static const struct option options[] = { 476static const struct option options[] = {
467 OPT_CALLBACK('e', "event", NULL, "event", 477 OPT_CALLBACK('e', "event", NULL, "event",
468 events_help_msg, parse_events), 478 events_help_msg, parse_events),
469 OPT_INTEGER('c', "count", &default_interval,
470 "event period to sample"),
471 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
472 "number of mmap data pages"),
473 OPT_STRING('o', "output", &output_name, "file",
474 "output file name"),
475 OPT_BOOLEAN('i', "inherit", &inherit,
476 "child tasks inherit counters"),
477 OPT_INTEGER('p', "pid", &target_pid, 479 OPT_INTEGER('p', "pid", &target_pid,
478 "record events on existing pid"), 480 "record events on existing pid"),
479 OPT_INTEGER('r', "realtime", &realtime_prio, 481 OPT_INTEGER('r', "realtime", &realtime_prio,
480 "collect data with this RT SCHED_FIFO priority"), 482 "collect data with this RT SCHED_FIFO priority"),
481 OPT_BOOLEAN('a', "all-cpus", &system_wide, 483 OPT_BOOLEAN('a', "all-cpus", &system_wide,
482 "system-wide collection from all CPUs"), 484 "system-wide collection from all CPUs"),
485 OPT_BOOLEAN('A', "append", &append_file,
486 "append to the output file to do incremental profiling"),
483 OPT_BOOLEAN('f', "force", &force, 487 OPT_BOOLEAN('f', "force", &force,
484 "overwrite existing data file"), 488 "overwrite existing data file"),
489 OPT_INTEGER('c', "count", &default_interval,
490 "event period to sample"),
491 OPT_STRING('o', "output", &output_name, "file",
492 "output file name"),
493 OPT_BOOLEAN('i', "inherit", &inherit,
494 "child tasks inherit counters"),
495 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
496 "number of mmap data pages"),
485 OPT_END() 497 OPT_END()
486}; 498};
487 499