aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds2012-12-11 20:14:31 -0600
committerLinus Torvalds2012-12-11 20:14:31 -0600
commit090f8ccba37034cec5a5972a70abeaae7eb0222b (patch)
tree0b7cf8a4bb94601816399acfb336835fbf309a2a /tools/perf/builtin-stat.c
parentaefb058b0c27dafb15072406fbfd92d2ac2c8790 (diff)
parentcc1b39dbf9f55a438e8a21a694394c20e6a17129 (diff)
downloadkernel-omap-090f8ccba37034cec5a5972a70abeaae7eb0222b.tar.gz
kernel-omap-090f8ccba37034cec5a5972a70abeaae7eb0222b.tar.xz
kernel-omap-090f8ccba37034cec5a5972a70abeaae7eb0222b.zip
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "Lots of activity: 211 files changed, 8328 insertions(+), 4116 deletions(-) most of it on the tooling side. Main changes: * ftrace enhancements and fixes from Steve Rostedt. * uprobes fixes, cleanups and preparation for the ARM port from Oleg Nesterov. * UAPI fixes, from David Howels - prepares the arch/x86 UAPI transition * Separate perf tests into multiple objects, one per test, from Jiri Olsa. * Make hardware event translations available in sysfs, from Jiri Olsa. * Fixes to /proc/pid/maps parsing, preparatory to supporting data maps, from Namhyung Kim * Implement ui_progress for GTK, from Namhyung Kim * Add framework for automated perf_event_attr tests, where tools with different command line options will be run from a 'perf test', via python glue, and the perf syscall will be intercepted to verify that the perf_event_attr fields set by the tool are those expected, from Jiri Olsa * Add a 'link' method for hists, so that we can have the leader with buckets for all the entries in all the hists. This new method is now used in the default 'diff' output, making the sum of the 'baseline' column be 100%, eliminating blind spots. * libtraceevent fixes for compiler warnings trying to make perf it build on some distros, like fedora 14, 32-bit, some of the warnings really pointed to real bugs. * Add a browser for 'perf script' and make it available from the report and annotate browsers. It does filtering to find the scripts that handle events found in the perf.data file used. From Feng Tang * perf inject changes to allow showing where a task sleeps, from Andrew Vagin. * Makefile improvements from Namhyung Kim. * Add --pre and --post command hooks in 'stat', from Peter Zijlstra. * Don't stop synthesizing threads when one vanishes, this is for the existing threads when we start a tool like trace. * Use sched:sched_stat_runtime to provide a thread summary, this produces the same output as the 'trace summary' subcommand of tglx's original "trace" tool. * Support interrupted syscalls in 'trace' * Add an event duration column and filter in 'trace'. * There are references to the man pages in some tools, so try to build Documentation when installing, warning the user if that is not possible, from Borislav Petkov. * Give user better message if precise is not supported, from David Ahern. * Try to find cross-built objdump path by using the session environment information in the perf.data file header, from Irina Tirdea, original patch and idea by Namhyung Kim. * Diplays more output on features check for make V=1, so that one can figure out what is happening by looking at gcc output, etc. From Jiri Olsa. * Add on_exit implementation for systems without one, e.g. Android, from Bernhard Rosenkraenzer. * Only process events for vcpus of interest, helps handling large number of events, from David Ahern. * Cross compilation fixes for Android, from Irina Tirdea. * Add documentation on compiling for Android, from Irina Tirdea. * perf diff improvements from Jiri Olsa. * Target (task/user/cpu/syswide) handling improvements, from Namhyung Kim. * Add support in 'trace' for tracing workload given by command line, from Namhyung Kim. * ... and much more." * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (194 commits) uprobes: Use percpu_rw_semaphore to fix register/unregister vs dup_mmap() race perf evsel: Introduce is_group_member method perf powerpc: Use uapi/unistd.h to fix build error tools: Pass the target in descend tools: Honour the O= flag when tool build called from a higher Makefile tools: Define a Makefile function to do subdir processing perf ui: Always compile browser setup code perf ui: Add ui_progress__finish() perf ui gtk: Implement ui_progress functions perf ui: Introduce generic ui_progress helper perf ui tui: Move progress.c under ui/tui directory perf tools: Add basic event modifier sanity check perf tools: Omit group members from perf_evlist__disable/enable perf tools: Ensure single disable call per event in record comand perf tools: Fix 'disabled' attribute config for record command perf tools: Fix attributes for '{}' defined event groups perf tools: Use sscanf for parsing /proc/pid/maps perf tools: Add gtk.<command> config option for launching GTK browser perf tools: Fix compile error on NO_NEWT=1 build perf hists: Initialize all of he->stat with zeroes ...
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r--tools/perf/builtin-stat.c54
1 files changed, 41 insertions, 13 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 93b9011fa3e2..c247faca7127 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -57,6 +57,7 @@
57#include "util/thread.h" 57#include "util/thread.h"
58#include "util/thread_map.h" 58#include "util/thread_map.h"
59 59
60#include <stdlib.h>
60#include <sys/prctl.h> 61#include <sys/prctl.h>
61#include <locale.h> 62#include <locale.h>
62 63
@@ -83,6 +84,9 @@ static const char *csv_sep = NULL;
83static bool csv_output = false; 84static bool csv_output = false;
84static bool group = false; 85static bool group = false;
85static FILE *output = NULL; 86static FILE *output = NULL;
87static const char *pre_cmd = NULL;
88static const char *post_cmd = NULL;
89static bool sync_run = false;
86 90
87static volatile int done = 0; 91static volatile int done = 0;
88 92
@@ -125,8 +129,7 @@ static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS];
125static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS]; 129static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS];
126static struct stats walltime_nsecs_stats; 130static struct stats walltime_nsecs_stats;
127 131
128static int create_perf_stat_counter(struct perf_evsel *evsel, 132static int create_perf_stat_counter(struct perf_evsel *evsel)
129 struct perf_evsel *first)
130{ 133{
131 struct perf_event_attr *attr = &evsel->attr; 134 struct perf_event_attr *attr = &evsel->attr;
132 bool exclude_guest_missing = false; 135 bool exclude_guest_missing = false;
@@ -149,7 +152,8 @@ retry:
149 return 0; 152 return 0;
150 } 153 }
151 154
152 if (!perf_target__has_task(&target) && (!group || evsel == first)) { 155 if (!perf_target__has_task(&target) &&
156 !perf_evsel__is_group_member(evsel)) {
153 attr->disabled = 1; 157 attr->disabled = 1;
154 attr->enable_on_exec = 1; 158 attr->enable_on_exec = 1;
155 } 159 }
@@ -265,10 +269,10 @@ static int read_counter(struct perf_evsel *counter)
265 return 0; 269 return 0;
266} 270}
267 271
268static int run_perf_stat(int argc __maybe_unused, const char **argv) 272static int __run_perf_stat(int argc __maybe_unused, const char **argv)
269{ 273{
270 unsigned long long t0, t1; 274 unsigned long long t0, t1;
271 struct perf_evsel *counter, *first; 275 struct perf_evsel *counter;
272 int status = 0; 276 int status = 0;
273 int child_ready_pipe[2], go_pipe[2]; 277 int child_ready_pipe[2], go_pipe[2];
274 const bool forks = (argc > 0); 278 const bool forks = (argc > 0);
@@ -328,10 +332,8 @@ static int run_perf_stat(int argc __maybe_unused, const char **argv)
328 if (group) 332 if (group)
329 perf_evlist__set_leader(evsel_list); 333 perf_evlist__set_leader(evsel_list);
330 334
331 first = perf_evlist__first(evsel_list);
332
333 list_for_each_entry(counter, &evsel_list->entries, node) { 335 list_for_each_entry(counter, &evsel_list->entries, node) {
334 if (create_perf_stat_counter(counter, first) < 0) { 336 if (create_perf_stat_counter(counter) < 0) {
335 /* 337 /*
336 * PPC returns ENXIO for HW counters until 2.6.37 338 * PPC returns ENXIO for HW counters until 2.6.37
337 * (behavior changed with commit b0a873e). 339 * (behavior changed with commit b0a873e).
@@ -405,6 +407,32 @@ static int run_perf_stat(int argc __maybe_unused, const char **argv)
405 return WEXITSTATUS(status); 407 return WEXITSTATUS(status);
406} 408}
407 409
410static int run_perf_stat(int argc __maybe_unused, const char **argv)
411{
412 int ret;
413
414 if (pre_cmd) {
415 ret = system(pre_cmd);
416 if (ret)
417 return ret;
418 }
419
420 if (sync_run)
421 sync();
422
423 ret = __run_perf_stat(argc, argv);
424 if (ret)
425 return ret;
426
427 if (post_cmd) {
428 ret = system(post_cmd);
429 if (ret)
430 return ret;
431 }
432
433 return ret;
434}
435
408static void print_noise_pct(double total, double avg) 436static void print_noise_pct(double total, double avg)
409{ 437{
410 double pct = rel_stddev_stats(total, avg); 438 double pct = rel_stddev_stats(total, avg);
@@ -1069,8 +1097,7 @@ static int add_default_attributes(void)
1069 1097
1070int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) 1098int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
1071{ 1099{
1072 bool append_file = false, 1100 bool append_file = false;
1073 sync_run = false;
1074 int output_fd = 0; 1101 int output_fd = 0;
1075 const char *output_name = NULL; 1102 const char *output_name = NULL;
1076 const struct option options[] = { 1103 const struct option options[] = {
@@ -1114,6 +1141,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
1114 OPT_BOOLEAN(0, "append", &append_file, "append to the output file"), 1141 OPT_BOOLEAN(0, "append", &append_file, "append to the output file"),
1115 OPT_INTEGER(0, "log-fd", &output_fd, 1142 OPT_INTEGER(0, "log-fd", &output_fd,
1116 "log output to fd, instead of stderr"), 1143 "log output to fd, instead of stderr"),
1144 OPT_STRING(0, "pre", &pre_cmd, "command",
1145 "command to run prior to the measured command"),
1146 OPT_STRING(0, "post", &post_cmd, "command",
1147 "command to run after to the measured command"),
1117 OPT_END() 1148 OPT_END()
1118 }; 1149 };
1119 const char * const stat_usage[] = { 1150 const char * const stat_usage[] = {
@@ -1238,9 +1269,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
1238 fprintf(output, "[ perf stat: executing run #%d ... ]\n", 1269 fprintf(output, "[ perf stat: executing run #%d ... ]\n",
1239 run_idx + 1); 1270 run_idx + 1);
1240 1271
1241 if (sync_run)
1242 sync();
1243
1244 status = run_perf_stat(argc, argv); 1272 status = run_perf_stat(argc, argv);
1245 } 1273 }
1246 1274