aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-09-08 07:26:02 -0400
committerIngo Molnar <mingo@kernel.org>2012-09-08 07:26:02 -0400
commitef34eb4da3eb62a1511592adf7c76d74faca0b14 (patch)
tree7f28887cf8c5d7059416769e152e79f68ce32830 /tools/perf
parent479d875835a49e849683743ec50c30b6a429696b (diff)
parentb155a09015135cf59ada8d48109ccbd9891c1b42 (diff)
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: * Fix build for another rbtree.c change, from Adrian Hunter. * Fixes for perf to build on Android, from Irina Tirdea. * Make 'perf diff' command work with evsel hists, from Jiri Olsa. * Use the only field_sep var that is set up: symbol_conf.field_sep, fix from Jiri Olsa. * .gitignore compiled python binaries, from Namhyung Kim. * Get rid of die() in more libtraceevent places, from Namhyung Kim. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/.gitignore2
-rw-r--r--tools/perf/Documentation/perf-diff.txt3
-rw-r--r--tools/perf/Makefile8
-rw-r--r--tools/perf/builtin-diff.c93
-rw-r--r--tools/perf/config/feature-tests.mak14
-rw-r--r--tools/perf/perf.c1
-rw-r--r--tools/perf/util/annotate.h1
-rw-r--r--tools/perf/util/dso-test-data.c2
-rw-r--r--tools/perf/util/evsel.h7
-rw-r--r--tools/perf/util/help.c1
-rw-r--r--tools/perf/util/include/linux/rbtree.h1
-rw-r--r--tools/perf/util/session.h4
-rw-r--r--tools/perf/util/sort.c6
-rw-r--r--tools/perf/util/sort.h1
-rw-r--r--tools/perf/util/symbol.h3
-rw-r--r--tools/perf/util/top.h1
-rw-r--r--tools/perf/util/util.c6
17 files changed, 113 insertions, 41 deletions
diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 26b823b61aa1..8f8fbc227a46 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -21,3 +21,5 @@ config.mak
21config.mak.autogen 21config.mak.autogen
22*-bison.* 22*-bison.*
23*-flex.* 23*-flex.*
24*.pyc
25*.pyo
diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index 74d7481ed7a6..ab7f667de1b1 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -17,6 +17,9 @@ captured via perf record.
17 17
18If no parameters are passed it will assume perf.data.old and perf.data. 18If no parameters are passed it will assume perf.data.old and perf.data.
19 19
20The differential profile is displayed only for events matching both
21specified perf.data files.
22
20OPTIONS 23OPTIONS
21------- 24-------
22-M:: 25-M::
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index afd507574902..3eda49215730 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -755,6 +755,14 @@ else
755 endif 755 endif
756endif 756endif
757 757
758ifdef NO_BACKTRACE
759 BASIC_CFLAGS += -DNO_BACKTRACE
760else
761 ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y)
762 BASIC_CFLAGS += -DNO_BACKTRACE
763 endif
764endif
765
758ifdef ASCIIDOC8 766ifdef ASCIIDOC8
759 export ASCIIDOC8 767 export ASCIIDOC8
760endif 768endif
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index d29d350fb2b7..e9933fdd256e 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -10,6 +10,7 @@
10#include "util/event.h" 10#include "util/event.h"
11#include "util/hist.h" 11#include "util/hist.h"
12#include "util/evsel.h" 12#include "util/evsel.h"
13#include "util/evlist.h"
13#include "util/session.h" 14#include "util/session.h"
14#include "util/tool.h" 15#include "util/tool.h"
15#include "util/sort.h" 16#include "util/sort.h"
@@ -24,11 +25,6 @@ static char diff__default_sort_order[] = "dso,symbol";
24static bool force; 25static bool force;
25static bool show_displacement; 26static bool show_displacement;
26 27
27struct perf_diff {
28 struct perf_tool tool;
29 struct perf_session *session;
30};
31
32static int hists__add_entry(struct hists *self, 28static int hists__add_entry(struct hists *self,
33 struct addr_location *al, u64 period) 29 struct addr_location *al, u64 period)
34{ 30{
@@ -37,14 +33,12 @@ static int hists__add_entry(struct hists *self,
37 return -ENOMEM; 33 return -ENOMEM;
38} 34}
39 35
40static int diff__process_sample_event(struct perf_tool *tool, 36static int diff__process_sample_event(struct perf_tool *tool __used,
41 union perf_event *event, 37 union perf_event *event,
42 struct perf_sample *sample, 38 struct perf_sample *sample,
43 struct perf_evsel *evsel __used, 39 struct perf_evsel *evsel,
44 struct machine *machine) 40 struct machine *machine)
45{ 41{
46 struct perf_diff *_diff = container_of(tool, struct perf_diff, tool);
47 struct perf_session *session = _diff->session;
48 struct addr_location al; 42 struct addr_location al;
49 43
50 if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) { 44 if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) {
@@ -56,26 +50,24 @@ static int diff__process_sample_event(struct perf_tool *tool,
56 if (al.filtered || al.sym == NULL) 50 if (al.filtered || al.sym == NULL)
57 return 0; 51 return 0;
58 52
59 if (hists__add_entry(&session->hists, &al, sample->period)) { 53 if (hists__add_entry(&evsel->hists, &al, sample->period)) {
60 pr_warning("problem incrementing symbol period, skipping event\n"); 54 pr_warning("problem incrementing symbol period, skipping event\n");
61 return -1; 55 return -1;
62 } 56 }
63 57
64 session->hists.stats.total_period += sample->period; 58 evsel->hists.stats.total_period += sample->period;
65 return 0; 59 return 0;
66} 60}
67 61
68static struct perf_diff diff = { 62static struct perf_tool tool = {
69 .tool = { 63 .sample = diff__process_sample_event,
70 .sample = diff__process_sample_event, 64 .mmap = perf_event__process_mmap,
71 .mmap = perf_event__process_mmap, 65 .comm = perf_event__process_comm,
72 .comm = perf_event__process_comm, 66 .exit = perf_event__process_task,
73 .exit = perf_event__process_task, 67 .fork = perf_event__process_task,
74 .fork = perf_event__process_task, 68 .lost = perf_event__process_lost,
75 .lost = perf_event__process_lost, 69 .ordered_samples = true,
76 .ordered_samples = true, 70 .ordering_requires_timestamps = true,
77 .ordering_requires_timestamps = true,
78 },
79}; 71};
80 72
81static void perf_session__insert_hist_entry_by_name(struct rb_root *root, 73static void perf_session__insert_hist_entry_by_name(struct rb_root *root,
@@ -146,34 +138,71 @@ static void hists__match(struct hists *older, struct hists *newer)
146 } 138 }
147} 139}
148 140
141static struct perf_evsel *evsel_match(struct perf_evsel *evsel,
142 struct perf_evlist *evlist)
143{
144 struct perf_evsel *e;
145
146 list_for_each_entry(e, &evlist->entries, node)
147 if (perf_evsel__match2(evsel, e))
148 return e;
149
150 return NULL;
151}
152
149static int __cmd_diff(void) 153static int __cmd_diff(void)
150{ 154{
151 int ret, i; 155 int ret, i;
152#define older (session[0]) 156#define older (session[0])
153#define newer (session[1]) 157#define newer (session[1])
154 struct perf_session *session[2]; 158 struct perf_session *session[2];
159 struct perf_evlist *evlist_new, *evlist_old;
160 struct perf_evsel *evsel;
161 bool first = true;
155 162
156 older = perf_session__new(input_old, O_RDONLY, force, false, 163 older = perf_session__new(input_old, O_RDONLY, force, false,
157 &diff.tool); 164 &tool);
158 newer = perf_session__new(input_new, O_RDONLY, force, false, 165 newer = perf_session__new(input_new, O_RDONLY, force, false,
159 &diff.tool); 166 &tool);
160 if (session[0] == NULL || session[1] == NULL) 167 if (session[0] == NULL || session[1] == NULL)
161 return -ENOMEM; 168 return -ENOMEM;
162 169
163 for (i = 0; i < 2; ++i) { 170 for (i = 0; i < 2; ++i) {
164 diff.session = session[i]; 171 ret = perf_session__process_events(session[i], &tool);
165 ret = perf_session__process_events(session[i], &diff.tool);
166 if (ret) 172 if (ret)
167 goto out_delete; 173 goto out_delete;
168 hists__output_resort(&session[i]->hists);
169 } 174 }
170 175
171 if (show_displacement) 176 evlist_old = older->evlist;
172 hists__resort_entries(&older->hists); 177 evlist_new = newer->evlist;
178
179 list_for_each_entry(evsel, &evlist_new->entries, node)
180 hists__output_resort(&evsel->hists);
181
182 list_for_each_entry(evsel, &evlist_old->entries, node) {
183 hists__output_resort(&evsel->hists);
184
185 if (show_displacement)
186 hists__resort_entries(&evsel->hists);
187 }
188
189 list_for_each_entry(evsel, &evlist_new->entries, node) {
190 struct perf_evsel *evsel_old;
191
192 evsel_old = evsel_match(evsel, evlist_old);
193 if (!evsel_old)
194 continue;
195
196 fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
197 perf_evsel__name(evsel));
198
199 first = false;
200
201 hists__match(&evsel_old->hists, &evsel->hists);
202 hists__fprintf(&evsel->hists, &evsel_old->hists,
203 show_displacement, true, 0, 0, stdout);
204 }
173 205
174 hists__match(&older->hists, &newer->hists);
175 hists__fprintf(&newer->hists, &older->hists,
176 show_displacement, true, 0, 0, stdout);
177out_delete: 206out_delete:
178 for (i = 0; i < 2; ++i) 207 for (i = 0; i < 2; ++i)
179 perf_session__delete(session[i]); 208 perf_session__delete(session[i]);
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
index 2f1156a62ab7..116690a669d2 100644
--- a/tools/perf/config/feature-tests.mak
+++ b/tools/perf/config/feature-tests.mak
@@ -179,3 +179,17 @@ int main(void)
179} 179}
180endef 180endef
181endif 181endif
182
183ifndef NO_BACKTRACE
184define SOURCE_BACKTRACE
185#include <execinfo.h>
186#include <stdio.h>
187
188int main(void)
189{
190 backtrace(NULL, 0);
191 backtrace_symbols(NULL, 0);
192 return 0;
193}
194endef
195endif
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index e7840e500715..fb8578cfa03c 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -14,6 +14,7 @@
14#include "util/run-command.h" 14#include "util/run-command.h"
15#include "util/parse-events.h" 15#include "util/parse-events.h"
16#include "util/debugfs.h" 16#include "util/debugfs.h"
17#include <pthread.h>
17 18
18const char perf_usage_string[] = 19const char perf_usage_string[] =
19 "perf [--version] [--help] COMMAND [ARGS]"; 20 "perf [--version] [--help] COMMAND [ARGS]";
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index a6d6bc5d7164..62a6e7a7365d 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -7,6 +7,7 @@
7#include "symbol.h" 7#include "symbol.h"
8#include <linux/list.h> 8#include <linux/list.h>
9#include <linux/rbtree.h> 9#include <linux/rbtree.h>
10#include <pthread.h>
10 11
11struct ins; 12struct ins;
12 13
diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c
index 541cdc72c7df..c6caedeb1d6b 100644
--- a/tools/perf/util/dso-test-data.c
+++ b/tools/perf/util/dso-test-data.c
@@ -23,7 +23,7 @@ static char *test_file(int size)
23 int fd, i; 23 int fd, i;
24 unsigned char *buf; 24 unsigned char *buf;
25 25
26 fd = mkostemp(templ, O_CREAT|O_WRONLY|O_TRUNC); 26 fd = mkstemp(templ);
27 27
28 buf = malloc(size); 28 buf = malloc(size);
29 if (!buf) { 29 if (!buf) {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index a3f562cec433..390690eb8781 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -124,6 +124,13 @@ void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads);
124 (evsel->attr.type == PERF_TYPE_##t && \ 124 (evsel->attr.type == PERF_TYPE_##t && \
125 evsel->attr.config == PERF_COUNT_##c) 125 evsel->attr.config == PERF_COUNT_##c)
126 126
127static inline bool perf_evsel__match2(struct perf_evsel *e1,
128 struct perf_evsel *e2)
129{
130 return (e1->attr.type == e2->attr.type) &&
131 (e1->attr.config == e2->attr.config);
132}
133
127int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, 134int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
128 int cpu, int thread, bool scale); 135 int cpu, int thread, bool scale);
129 136
diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c
index 6f2975a00358..4fa764d8f7d7 100644
--- a/tools/perf/util/help.c
+++ b/tools/perf/util/help.c
@@ -3,6 +3,7 @@
3#include "exec_cmd.h" 3#include "exec_cmd.h"
4#include "levenshtein.h" 4#include "levenshtein.h"
5#include "help.h" 5#include "help.h"
6#include <termios.h>
6 7
7void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) 8void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
8{ 9{
diff --git a/tools/perf/util/include/linux/rbtree.h b/tools/perf/util/include/linux/rbtree.h
index 7a243a143037..2a030c5af3aa 100644
--- a/tools/perf/util/include/linux/rbtree.h
+++ b/tools/perf/util/include/linux/rbtree.h
@@ -1 +1,2 @@
1#include <stdbool.h>
1#include "../../../../include/linux/rbtree.h" 2#include "../../../../include/linux/rbtree.h"
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 176a60902f56..aab414fbb64b 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -36,9 +36,7 @@ struct perf_session {
36 struct pevent *pevent; 36 struct pevent *pevent;
37 /* 37 /*
38 * FIXME: Need to split this up further, we need global 38 * FIXME: Need to split this up further, we need global
39 * stats + per event stats. 'perf diff' also needs 39 * stats + per event stats.
40 * to properly support multiple events in a single
41 * perf.data file.
42 */ 40 */
43 struct hists hists; 41 struct hists hists;
44 int fd; 42 int fd;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 0f5a0a496bc4..7a2fbd8855b7 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -12,8 +12,6 @@ int sort__branch_mode = -1; /* -1 = means not set */
12 12
13enum sort_type sort__first_dimension; 13enum sort_type sort__first_dimension;
14 14
15char * field_sep;
16
17LIST_HEAD(hist_entry__sort_list); 15LIST_HEAD(hist_entry__sort_list);
18 16
19static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...) 17static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
@@ -23,11 +21,11 @@ static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
23 21
24 va_start(ap, fmt); 22 va_start(ap, fmt);
25 n = vsnprintf(bf, size, fmt, ap); 23 n = vsnprintf(bf, size, fmt, ap);
26 if (field_sep && n > 0) { 24 if (symbol_conf.field_sep && n > 0) {
27 char *sep = bf; 25 char *sep = bf;
28 26
29 while (1) { 27 while (1) {
30 sep = strchr(sep, *field_sep); 28 sep = strchr(sep, *symbol_conf.field_sep);
31 if (sep == NULL) 29 if (sep == NULL)
32 break; 30 break;
33 *sep = '.'; 31 *sep = '.';
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index e724b26acd51..e459c981b039 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -32,7 +32,6 @@ extern const char default_sort_order[];
32extern int sort__need_collapse; 32extern int sort__need_collapse;
33extern int sort__has_parent; 33extern int sort__has_parent;
34extern int sort__branch_mode; 34extern int sort__branch_mode;
35extern char *field_sep;
36extern struct sort_entry sort_comm; 35extern struct sort_entry sort_comm;
37extern struct sort_entry sort_dso; 36extern struct sort_entry sort_dso;
38extern struct sort_entry sort_sym; 37extern struct sort_entry sort_sym;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index fc4b1e630fd9..d3b330cbc3e0 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -10,6 +10,9 @@
10#include <linux/rbtree.h> 10#include <linux/rbtree.h>
11#include <stdio.h> 11#include <stdio.h>
12#include <byteswap.h> 12#include <byteswap.h>
13#if defined(__BIONIC__)
14#include <libgen.h>
15#endif
13 16
14#ifndef NO_LIBELF_SUPPORT 17#ifndef NO_LIBELF_SUPPORT
15#include <libelf.h> 18#include <libelf.h>
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index 33347ca89ee4..86ff1b15059b 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -5,6 +5,7 @@
5#include "types.h" 5#include "types.h"
6#include <stddef.h> 6#include <stddef.h>
7#include <stdbool.h> 7#include <stdbool.h>
8#include <termios.h>
8 9
9struct perf_evlist; 10struct perf_evlist;
10struct perf_evsel; 11struct perf_evsel;
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 1b8775c3707d..2055cf38041c 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -1,7 +1,9 @@
1#include "../perf.h" 1#include "../perf.h"
2#include "util.h" 2#include "util.h"
3#include <sys/mman.h> 3#include <sys/mman.h>
4#ifndef NO_BACKTRACE
4#include <execinfo.h> 5#include <execinfo.h>
6#endif
5#include <stdio.h> 7#include <stdio.h>
6#include <stdlib.h> 8#include <stdlib.h>
7 9
@@ -163,6 +165,7 @@ size_t hex_width(u64 v)
163} 165}
164 166
165/* Obtain a backtrace and print it to stdout. */ 167/* Obtain a backtrace and print it to stdout. */
168#ifndef NO_BACKTRACE
166void dump_stack(void) 169void dump_stack(void)
167{ 170{
168 void *array[16]; 171 void *array[16];
@@ -177,3 +180,6 @@ void dump_stack(void)
177 180
178 free(strings); 181 free(strings);
179} 182}
183#else
184void dump_stack(void) {}
185#endif