aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Makefile8
-rw-r--r--tools/perf/builtin-buildid-list.c2
-rw-r--r--tools/perf/builtin-diff.c3
-rw-r--r--tools/perf/builtin-kmem.c4
-rw-r--r--tools/perf/builtin-record.c14
-rw-r--r--tools/perf/builtin-report.c3
-rw-r--r--tools/perf/builtin-trace.c4
-rw-r--r--tools/perf/design.txt8
8 files changed, 28 insertions, 18 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 4390d225686d..652a470b5f74 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -343,13 +343,18 @@ LIB_H += util/include/linux/string.h
343LIB_H += util/include/linux/types.h 343LIB_H += util/include/linux/types.h
344LIB_H += util/include/asm/asm-offsets.h 344LIB_H += util/include/asm/asm-offsets.h
345LIB_H += util/include/asm/bitops.h 345LIB_H += util/include/asm/bitops.h
346LIB_H += util/include/asm/bug.h
346LIB_H += util/include/asm/byteorder.h 347LIB_H += util/include/asm/byteorder.h
347LIB_H += util/include/asm/swab.h 348LIB_H += util/include/asm/swab.h
348LIB_H += util/include/asm/system.h 349LIB_H += util/include/asm/system.h
349LIB_H += util/include/asm/uaccess.h 350LIB_H += util/include/asm/uaccess.h
350LIB_H += perf.h 351LIB_H += perf.h
352LIB_H += util/cache.h
353LIB_H += util/callchain.h
354LIB_H += util/debug.h
351LIB_H += util/debugfs.h 355LIB_H += util/debugfs.h
352LIB_H += util/event.h 356LIB_H += util/event.h
357LIB_H += util/exec_cmd.h
353LIB_H += util/types.h 358LIB_H += util/types.h
354LIB_H += util/levenshtein.h 359LIB_H += util/levenshtein.h
355LIB_H += util/parse-options.h 360LIB_H += util/parse-options.h
@@ -362,6 +367,7 @@ LIB_H += util/session.h
362LIB_H += util/strbuf.h 367LIB_H += util/strbuf.h
363LIB_H += util/string.h 368LIB_H += util/string.h
364LIB_H += util/strlist.h 369LIB_H += util/strlist.h
370LIB_H += util/svghelper.h
365LIB_H += util/run-command.h 371LIB_H += util/run-command.h
366LIB_H += util/sigchain.h 372LIB_H += util/sigchain.h
367LIB_H += util/symbol.h 373LIB_H += util/symbol.h
@@ -370,6 +376,8 @@ LIB_H += util/values.h
370LIB_H += util/sort.h 376LIB_H += util/sort.h
371LIB_H += util/hist.h 377LIB_H += util/hist.h
372LIB_H += util/thread.h 378LIB_H += util/thread.h
379LIB_H += util/trace-event.h
380LIB_H += util/trace-event-perl.h
373LIB_H += util/probe-finder.h 381LIB_H += util/probe-finder.h
374LIB_H += util/probe-event.h 382LIB_H += util/probe-event.h
375 383
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index e693e6777af5..1e99ac806913 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -17,7 +17,7 @@
17static char const *input_name = "perf.data"; 17static char const *input_name = "perf.data";
18static int force; 18static int force;
19 19
20static const char *const buildid_list_usage[] = { 20static const char * const buildid_list_usage[] = {
21 "perf buildid-list [<options>]", 21 "perf buildid-list [<options>]",
22 NULL 22 NULL
23}; 23};
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 4d33b55d5584..bd71b8ceafb7 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -189,8 +189,9 @@ out_delete:
189 return ret; 189 return ret;
190} 190}
191 191
192static const char *const diff_usage[] = { 192static const char * const diff_usage[] = {
193 "perf diff [<options>] [old_file] [new_file]", 193 "perf diff [<options>] [old_file] [new_file]",
194 NULL,
194}; 195};
195 196
196static const struct option options[] = { 197static const struct option options[] = {
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index fc21ad79dd83..7ceb7416c316 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -137,7 +137,7 @@ static void insert_alloc_stat(unsigned long call_site, unsigned long ptr,
137 if (data && data->ptr == ptr) { 137 if (data && data->ptr == ptr) {
138 data->hit++; 138 data->hit++;
139 data->bytes_req += bytes_req; 139 data->bytes_req += bytes_req;
140 data->bytes_alloc += bytes_req; 140 data->bytes_alloc += bytes_alloc;
141 } else { 141 } else {
142 data = malloc(sizeof(*data)); 142 data = malloc(sizeof(*data));
143 if (!data) 143 if (!data)
@@ -177,7 +177,7 @@ static void insert_caller_stat(unsigned long call_site,
177 if (data && data->call_site == call_site) { 177 if (data && data->call_site == call_site) {
178 data->hit++; 178 data->hit++;
179 data->bytes_req += bytes_req; 179 data->bytes_req += bytes_req;
180 data->bytes_alloc += bytes_req; 180 data->bytes_alloc += bytes_alloc;
181 } else { 181 } else {
182 data = malloc(sizeof(*data)); 182 data = malloc(sizeof(*data));
183 if (!data) 183 if (!data)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 63136d0534d4..265425322734 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -402,7 +402,7 @@ static void atexit_header(void)
402 perf_header__write(&session->header, output, true); 402 perf_header__write(&session->header, output, true);
403} 403}
404 404
405static int __cmd_record(int argc __used, const char **argv) 405static int __cmd_record(int argc, const char **argv)
406{ 406{
407 int i, counter; 407 int i, counter;
408 struct stat st; 408 struct stat st;
@@ -411,6 +411,7 @@ static int __cmd_record(int argc __used, const char **argv)
411 int err; 411 int err;
412 unsigned long waking = 0; 412 unsigned long waking = 0;
413 int child_ready_pipe[2], go_pipe[2]; 413 int child_ready_pipe[2], go_pipe[2];
414 const bool forks = target_pid == -1 && argc > 0;
414 char buf; 415 char buf;
415 416
416 page_size = sysconf(_SC_PAGE_SIZE); 417 page_size = sysconf(_SC_PAGE_SIZE);
@@ -422,7 +423,7 @@ static int __cmd_record(int argc __used, const char **argv)
422 signal(SIGCHLD, sig_handler); 423 signal(SIGCHLD, sig_handler);
423 signal(SIGINT, sig_handler); 424 signal(SIGINT, sig_handler);
424 425
425 if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) { 426 if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
426 perror("failed to create pipes"); 427 perror("failed to create pipes");
427 exit(-1); 428 exit(-1);
428 } 429 }
@@ -483,7 +484,7 @@ static int __cmd_record(int argc __used, const char **argv)
483 484
484 atexit(atexit_header); 485 atexit(atexit_header);
485 486
486 if (target_pid == -1) { 487 if (forks) {
487 pid = fork(); 488 pid = fork();
488 if (pid < 0) { 489 if (pid < 0) {
489 perror("failed to fork"); 490 perror("failed to fork");
@@ -550,7 +551,7 @@ static int __cmd_record(int argc __used, const char **argv)
550 return err; 551 return err;
551 } 552 }
552 553
553 if (!system_wide) 554 if (!system_wide && profile_cpu == -1)
554 event__synthesize_thread(pid, process_synthesized_event, 555 event__synthesize_thread(pid, process_synthesized_event,
555 session); 556 session);
556 else 557 else
@@ -569,7 +570,8 @@ static int __cmd_record(int argc __used, const char **argv)
569 /* 570 /*
570 * Let the child rip 571 * Let the child rip
571 */ 572 */
572 close(go_pipe[1]); 573 if (forks)
574 close(go_pipe[1]);
573 575
574 for (;;) { 576 for (;;) {
575 int hits = samples; 577 int hits = samples;
@@ -667,7 +669,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
667 669
668 argc = parse_options(argc, argv, options, record_usage, 670 argc = parse_options(argc, argv, options, record_usage,
669 PARSE_OPT_STOP_AT_NON_OPTION); 671 PARSE_OPT_STOP_AT_NON_OPTION);
670 if (!argc && target_pid == -1 && (!system_wide || profile_cpu == -1)) 672 if (!argc && target_pid == -1 && !system_wide && profile_cpu == -1)
671 usage_with_options(record_usage, options); 673 usage_with_options(record_usage, options);
672 674
673 symbol__init(); 675 symbol__init();
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 5c2ab5357ec6..db10c0e8ecae 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -294,8 +294,7 @@ setup:
294 return 0; 294 return 0;
295} 295}
296 296
297//static const char * const report_usage[] = { 297static const char * const report_usage[] = {
298const char * const report_usage[] = {
299 "perf report [<options>] <command>", 298 "perf report [<options>] <command>",
300 NULL 299 NULL
301}; 300};
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e2285e28720f..574a215e800b 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -512,7 +512,7 @@ static char *get_script_path(const char *script_root, const char *suffix)
512 return path; 512 return path;
513} 513}
514 514
515static const char * const annotate_usage[] = { 515static const char * const trace_usage[] = {
516 "perf trace [<options>] <command>", 516 "perf trace [<options>] <command>",
517 NULL 517 NULL
518}; 518};
@@ -581,7 +581,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
581 581
582 setup_scripting(); 582 setup_scripting();
583 583
584 argc = parse_options(argc, argv, options, annotate_usage, 584 argc = parse_options(argc, argv, options, trace_usage,
585 PARSE_OPT_STOP_AT_NON_OPTION); 585 PARSE_OPT_STOP_AT_NON_OPTION);
586 586
587 if (symbol__init() < 0) 587 if (symbol__init() < 0)
diff --git a/tools/perf/design.txt b/tools/perf/design.txt
index f000c30877ac..8d0de5130db3 100644
--- a/tools/perf/design.txt
+++ b/tools/perf/design.txt
@@ -21,7 +21,7 @@ There's one file descriptor per virtual counter used.
21The special file descriptor is opened via the perf_event_open() 21The special file descriptor is opened via the perf_event_open()
22system call: 22system call:
23 23
24 int sys_perf_event_open(struct perf_event_hw_event *hw_event_uptr, 24 int sys_perf_event_open(struct perf_event_attr *hw_event_uptr,
25 pid_t pid, int cpu, int group_fd, 25 pid_t pid, int cpu, int group_fd,
26 unsigned long flags); 26 unsigned long flags);
27 27
@@ -32,9 +32,9 @@ can be used to set the blocking mode, etc.
32Multiple counters can be kept open at a time, and the counters 32Multiple counters can be kept open at a time, and the counters
33can be poll()ed. 33can be poll()ed.
34 34
35When creating a new counter fd, 'perf_event_hw_event' is: 35When creating a new counter fd, 'perf_event_attr' is:
36 36
37struct perf_event_hw_event { 37struct perf_event_attr {
38 /* 38 /*
39 * The MSB of the config word signifies if the rest contains cpu 39 * The MSB of the config word signifies if the rest contains cpu
40 * specific (raw) counter configuration data, if unset, the next 40 * specific (raw) counter configuration data, if unset, the next
@@ -399,7 +399,7 @@ Notification of new events is possible through poll()/select()/epoll() and
399fcntl() managing signals. 399fcntl() managing signals.
400 400
401Normally a notification is generated for every page filled, however one can 401Normally a notification is generated for every page filled, however one can
402additionally set perf_event_hw_event.wakeup_events to generate one every 402additionally set perf_event_attr.wakeup_events to generate one every
403so many counter overflow events. 403so many counter overflow events.
404 404
405Future work will include a splice() interface to the ring-buffer. 405Future work will include a splice() interface to the ring-buffer.