aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-01-16 03:34:01 -0500
committerIngo Molnar <mingo@kernel.org>2014-01-16 03:34:01 -0500
commit3e7e09dbd1080de5dcf10092830e39bc2e2932ec (patch)
tree546c99c62fd8a37511cafeb38e9532fda4b150fd /tools
parent860fc2f2640ec348b9520ca4649b1bfd23d91bc2 (diff)
parent0e9e79a13ab9d56b86db6538305babc23b1445cc (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 updates from Arnaldo Carvalho de Melo: Changes in user visible interfaces: * Rename 'record's --no-delay option to --no-buffering, better reflecting its purpose and freeing up '--delay' to take the place of '--initial-delay', so that 'record' and 'stat' are consistent. Refactorings: * Get rid of die() and friends (good riddance!) in libtraceevent (Namhyung Kim) Infrastructure enhancements: * Fix cross build problems related to pkgconfig and CROSS_COMPILE not being propagated to the feature tests, leading to features being tested in the host and then being enabled on the target. (Mark Rutland) * Fix pointer-integer size mismatch in some libtraceevent plugins (Mark Rutland) * Fix build error due to zfree() cast (Namhyung Kim) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/traceevent/Makefile2
-rw-r--r--tools/lib/traceevent/event-parse.h14
-rw-r--r--tools/lib/traceevent/event-plugin.c4
-rw-r--r--tools/lib/traceevent/event-utils.h4
-rw-r--r--tools/lib/traceevent/parse-utils.c44
-rw-r--r--tools/lib/traceevent/plugin_cfg80211.c2
-rw-r--r--tools/lib/traceevent/plugin_function.c2
-rw-r--r--tools/lib/traceevent/plugin_scsi.c2
-rw-r--r--tools/lib/traceevent/trace-seq.c67
-rw-r--r--tools/perf/Documentation/perf-record.txt6
-rw-r--r--tools/perf/Makefile.perf1
-rw-r--r--tools/perf/builtin-record.c4
-rw-r--r--tools/perf/builtin-report.c24
-rw-r--r--tools/perf/builtin-top.c22
-rw-r--r--tools/perf/builtin-trace.c2
-rw-r--r--tools/perf/config/Makefile6
-rw-r--r--tools/perf/config/feature-checks/Makefile9
-rw-r--r--tools/perf/perf.h2
-rw-r--r--tools/perf/tests/open-syscall-tp-fields.c8
-rw-r--r--tools/perf/tests/perf-record.c6
-rw-r--r--tools/perf/util/callchain.c23
-rw-r--r--tools/perf/util/callchain.h6
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/hist.c22
-rw-r--r--tools/perf/util/machine.c2
-rw-r--r--tools/perf/util/srcline.c4
-rw-r--r--tools/perf/util/strlist.c2
-rw-r--r--tools/perf/util/trace-event.c2
28 files changed, 147 insertions, 147 deletions
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index f778d48ac609..56d52a33a3df 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -136,7 +136,7 @@ export Q VERBOSE
136 136
137EVENT_PARSE_VERSION = $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION) 137EVENT_PARSE_VERSION = $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION)
138 138
139INCLUDES = -I. $(CONFIG_INCLUDES) 139INCLUDES = -I. -I $(srctree)/../../include $(CONFIG_INCLUDES)
140 140
141# Set compile option CFLAGS if not set elsewhere 141# Set compile option CFLAGS if not set elsewhere
142CFLAGS ?= -g -Wall 142CFLAGS ?= -g -Wall
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index cf5db9013f2c..a3beca56cb35 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -58,6 +58,12 @@ struct pevent_record {
58#endif 58#endif
59}; 59};
60 60
61enum trace_seq_fail {
62 TRACE_SEQ__GOOD,
63 TRACE_SEQ__BUFFER_POISONED,
64 TRACE_SEQ__MEM_ALLOC_FAILED,
65};
66
61/* 67/*
62 * Trace sequences are used to allow a function to call several other functions 68 * Trace sequences are used to allow a function to call several other functions
63 * to create a string of data to use (up to a max of PAGE_SIZE). 69 * to create a string of data to use (up to a max of PAGE_SIZE).
@@ -68,6 +74,7 @@ struct trace_seq {
68 unsigned int buffer_size; 74 unsigned int buffer_size;
69 unsigned int len; 75 unsigned int len;
70 unsigned int readpos; 76 unsigned int readpos;
77 enum trace_seq_fail state;
71}; 78};
72 79
73void trace_seq_init(struct trace_seq *s); 80void trace_seq_init(struct trace_seq *s);
@@ -98,7 +105,7 @@ typedef int (*pevent_event_handler_func)(struct trace_seq *s,
98 void *context); 105 void *context);
99 106
100typedef int (*pevent_plugin_load_func)(struct pevent *pevent); 107typedef int (*pevent_plugin_load_func)(struct pevent *pevent);
101typedef int (*pevent_plugin_unload_func)(void); 108typedef int (*pevent_plugin_unload_func)(struct pevent *pevent);
102 109
103struct plugin_option { 110struct plugin_option {
104 struct plugin_option *next; 111 struct plugin_option *next;
@@ -123,7 +130,7 @@ struct plugin_option {
123 * PEVENT_PLUGIN_UNLOADER: (optional) 130 * PEVENT_PLUGIN_UNLOADER: (optional)
124 * The function called just before unloading 131 * The function called just before unloading
125 * 132 *
126 * int PEVENT_PLUGIN_UNLOADER(void) 133 * int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
127 * 134 *
128 * PEVENT_PLUGIN_OPTIONS: (optional) 135 * PEVENT_PLUGIN_OPTIONS: (optional)
129 * Plugin options that can be set before loading 136 * Plugin options that can be set before loading
@@ -404,7 +411,8 @@ enum pevent_errno {
404struct plugin_list; 411struct plugin_list;
405 412
406struct plugin_list *traceevent_load_plugins(struct pevent *pevent); 413struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
407void traceevent_unload_plugins(struct plugin_list *plugin_list); 414void traceevent_unload_plugins(struct plugin_list *plugin_list,
415 struct pevent *pevent);
408 416
409struct cmdline; 417struct cmdline;
410struct cmdline_list; 418struct cmdline_list;
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index 125f5676bcb5..0c8bf6780e4d 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -197,7 +197,7 @@ traceevent_load_plugins(struct pevent *pevent)
197} 197}
198 198
199void 199void
200traceevent_unload_plugins(struct plugin_list *plugin_list) 200traceevent_unload_plugins(struct plugin_list *plugin_list, struct pevent *pevent)
201{ 201{
202 pevent_plugin_unload_func func; 202 pevent_plugin_unload_func func;
203 struct plugin_list *list; 203 struct plugin_list *list;
@@ -207,7 +207,7 @@ traceevent_unload_plugins(struct plugin_list *plugin_list)
207 plugin_list = list->next; 207 plugin_list = list->next;
208 func = dlsym(list->handle, PEVENT_PLUGIN_UNLOADER_NAME); 208 func = dlsym(list->handle, PEVENT_PLUGIN_UNLOADER_NAME);
209 if (func) 209 if (func)
210 func(); 210 func(pevent);
211 dlclose(list->handle); 211 dlclose(list->handle);
212 free(list->name); 212 free(list->name);
213 free(list); 213 free(list);
diff --git a/tools/lib/traceevent/event-utils.h b/tools/lib/traceevent/event-utils.h
index e76c9acb92cd..d1dc2170e402 100644
--- a/tools/lib/traceevent/event-utils.h
+++ b/tools/lib/traceevent/event-utils.h
@@ -23,18 +23,14 @@
23#include <ctype.h> 23#include <ctype.h>
24 24
25/* Can be overridden */ 25/* Can be overridden */
26void die(const char *fmt, ...);
27void *malloc_or_die(unsigned int size);
28void warning(const char *fmt, ...); 26void warning(const char *fmt, ...);
29void pr_stat(const char *fmt, ...); 27void pr_stat(const char *fmt, ...);
30void vpr_stat(const char *fmt, va_list ap); 28void vpr_stat(const char *fmt, va_list ap);
31 29
32/* Always available */ 30/* Always available */
33void __die(const char *fmt, ...);
34void __warning(const char *fmt, ...); 31void __warning(const char *fmt, ...);
35void __pr_stat(const char *fmt, ...); 32void __pr_stat(const char *fmt, ...);
36 33
37void __vdie(const char *fmt, ...);
38void __vwarning(const char *fmt, ...); 34void __vwarning(const char *fmt, ...);
39void __vpr_stat(const char *fmt, ...); 35void __vpr_stat(const char *fmt, ...);
40 36
diff --git a/tools/lib/traceevent/parse-utils.c b/tools/lib/traceevent/parse-utils.c
index bba701cf10e6..eda07fa31dca 100644
--- a/tools/lib/traceevent/parse-utils.c
+++ b/tools/lib/traceevent/parse-utils.c
@@ -25,40 +25,6 @@
25 25
26#define __weak __attribute__((weak)) 26#define __weak __attribute__((weak))
27 27
28void __vdie(const char *fmt, va_list ap)
29{
30 int ret = errno;
31
32 if (errno)
33 perror("trace-cmd");
34 else
35 ret = -1;
36
37 fprintf(stderr, " ");
38 vfprintf(stderr, fmt, ap);
39
40 fprintf(stderr, "\n");
41 exit(ret);
42}
43
44void __die(const char *fmt, ...)
45{
46 va_list ap;
47
48 va_start(ap, fmt);
49 __vdie(fmt, ap);
50 va_end(ap);
51}
52
53void __weak die(const char *fmt, ...)
54{
55 va_list ap;
56
57 va_start(ap, fmt);
58 __vdie(fmt, ap);
59 va_end(ap);
60}
61
62void __vwarning(const char *fmt, va_list ap) 28void __vwarning(const char *fmt, va_list ap)
63{ 29{
64 if (errno) 30 if (errno)
@@ -117,13 +83,3 @@ void __weak pr_stat(const char *fmt, ...)
117 __vpr_stat(fmt, ap); 83 __vpr_stat(fmt, ap);
118 va_end(ap); 84 va_end(ap);
119} 85}
120
121void __weak *malloc_or_die(unsigned int size)
122{
123 void *data;
124
125 data = malloc(size);
126 if (!data)
127 die("malloc");
128 return data;
129}
diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c
index dcab8e873c21..57e98221db20 100644
--- a/tools/lib/traceevent/plugin_cfg80211.c
+++ b/tools/lib/traceevent/plugin_cfg80211.c
@@ -8,7 +8,7 @@ static unsigned long long
8process___le16_to_cpup(struct trace_seq *s, 8process___le16_to_cpup(struct trace_seq *s,
9 unsigned long long *args) 9 unsigned long long *args)
10{ 10{
11 uint16_t *val = (uint16_t *) args[0]; 11 uint16_t *val = (uint16_t *) (unsigned long) args[0];
12 return val ? (long long) le16toh(*val) : 0; 12 return val ? (long long) le16toh(*val) : 0;
13} 13}
14 14
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
index aad92ad5e96f..39461485f9a7 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -144,7 +144,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
144 return 0; 144 return 0;
145} 145}
146 146
147void PEVENT_PLUGIN_UNLOADER(void) 147void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
148{ 148{
149 int i, x; 149 int i, x;
150 150
diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
index 6fb8e3e3fcad..7ef16cc96562 100644
--- a/tools/lib/traceevent/plugin_scsi.c
+++ b/tools/lib/traceevent/plugin_scsi.c
@@ -405,7 +405,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
405unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s, 405unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
406 unsigned long long *args) 406 unsigned long long *args)
407{ 407{
408 scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]); 408 scsi_trace_parse_cdb(s, (unsigned char *) (unsigned long) args[1], args[2]);
409 return 0; 409 return 0;
410} 410}
411 411
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index d7f2e68bc5b9..ec3bd16a5488 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/lib/traceevent/trace-seq.c
@@ -22,6 +22,7 @@
22#include <string.h> 22#include <string.h>
23#include <stdarg.h> 23#include <stdarg.h>
24 24
25#include <asm/bug.h>
25#include "event-parse.h" 26#include "event-parse.h"
26#include "event-utils.h" 27#include "event-utils.h"
27 28
@@ -32,10 +33,21 @@
32#define TRACE_SEQ_POISON ((void *)0xdeadbeef) 33#define TRACE_SEQ_POISON ((void *)0xdeadbeef)
33#define TRACE_SEQ_CHECK(s) \ 34#define TRACE_SEQ_CHECK(s) \
34do { \ 35do { \
35 if ((s)->buffer == TRACE_SEQ_POISON) \ 36 if (WARN_ONCE((s)->buffer == TRACE_SEQ_POISON, \
36 die("Usage of trace_seq after it was destroyed"); \ 37 "Usage of trace_seq after it was destroyed")) \
38 (s)->state = TRACE_SEQ__BUFFER_POISONED; \
37} while (0) 39} while (0)
38 40
41#define TRACE_SEQ_CHECK_RET_N(s, n) \
42do { \
43 TRACE_SEQ_CHECK(s); \
44 if ((s)->state != TRACE_SEQ__GOOD) \
45 return n; \
46} while (0)
47
48#define TRACE_SEQ_CHECK_RET(s) TRACE_SEQ_CHECK_RET_N(s, )
49#define TRACE_SEQ_CHECK_RET0(s) TRACE_SEQ_CHECK_RET_N(s, 0)
50
39/** 51/**
40 * trace_seq_init - initialize the trace_seq structure 52 * trace_seq_init - initialize the trace_seq structure
41 * @s: a pointer to the trace_seq structure to initialize 53 * @s: a pointer to the trace_seq structure to initialize
@@ -45,7 +57,11 @@ void trace_seq_init(struct trace_seq *s)
45 s->len = 0; 57 s->len = 0;
46 s->readpos = 0; 58 s->readpos = 0;
47 s->buffer_size = TRACE_SEQ_BUF_SIZE; 59 s->buffer_size = TRACE_SEQ_BUF_SIZE;
48 s->buffer = malloc_or_die(s->buffer_size); 60 s->buffer = malloc(s->buffer_size);
61 if (s->buffer != NULL)
62 s->state = TRACE_SEQ__GOOD;
63 else
64 s->state = TRACE_SEQ__MEM_ALLOC_FAILED;
49} 65}
50 66
51/** 67/**
@@ -71,17 +87,23 @@ void trace_seq_destroy(struct trace_seq *s)
71{ 87{
72 if (!s) 88 if (!s)
73 return; 89 return;
74 TRACE_SEQ_CHECK(s); 90 TRACE_SEQ_CHECK_RET(s);
75 free(s->buffer); 91 free(s->buffer);
76 s->buffer = TRACE_SEQ_POISON; 92 s->buffer = TRACE_SEQ_POISON;
77} 93}
78 94
79static void expand_buffer(struct trace_seq *s) 95static void expand_buffer(struct trace_seq *s)
80{ 96{
97 char *buf;
98
99 buf = realloc(s->buffer, s->buffer_size + TRACE_SEQ_BUF_SIZE);
100 if (WARN_ONCE(!buf, "Can't allocate trace_seq buffer memory")) {
101 s->state = TRACE_SEQ__MEM_ALLOC_FAILED;
102 return;
103 }
104
105 s->buffer = buf;
81 s->buffer_size += TRACE_SEQ_BUF_SIZE; 106 s->buffer_size += TRACE_SEQ_BUF_SIZE;
82 s->buffer = realloc(s->buffer, s->buffer_size);
83 if (!s->buffer)
84 die("Can't allocate trace_seq buffer memory");
85} 107}
86 108
87/** 109/**
@@ -105,9 +127,9 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
105 int len; 127 int len;
106 int ret; 128 int ret;
107 129
108 TRACE_SEQ_CHECK(s);
109
110 try_again: 130 try_again:
131 TRACE_SEQ_CHECK_RET0(s);
132
111 len = (s->buffer_size - 1) - s->len; 133 len = (s->buffer_size - 1) - s->len;
112 134
113 va_start(ap, fmt); 135 va_start(ap, fmt);
@@ -141,9 +163,9 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
141 int len; 163 int len;
142 int ret; 164 int ret;
143 165
144 TRACE_SEQ_CHECK(s);
145
146 try_again: 166 try_again:
167 TRACE_SEQ_CHECK_RET0(s);
168
147 len = (s->buffer_size - 1) - s->len; 169 len = (s->buffer_size - 1) - s->len;
148 170
149 ret = vsnprintf(s->buffer + s->len, len, fmt, args); 171 ret = vsnprintf(s->buffer + s->len, len, fmt, args);
@@ -172,13 +194,15 @@ int trace_seq_puts(struct trace_seq *s, const char *str)
172{ 194{
173 int len; 195 int len;
174 196
175 TRACE_SEQ_CHECK(s); 197 TRACE_SEQ_CHECK_RET0(s);
176 198
177 len = strlen(str); 199 len = strlen(str);
178 200
179 while (len > ((s->buffer_size - 1) - s->len)) 201 while (len > ((s->buffer_size - 1) - s->len))
180 expand_buffer(s); 202 expand_buffer(s);
181 203
204 TRACE_SEQ_CHECK_RET0(s);
205
182 memcpy(s->buffer + s->len, str, len); 206 memcpy(s->buffer + s->len, str, len);
183 s->len += len; 207 s->len += len;
184 208
@@ -187,11 +211,13 @@ int trace_seq_puts(struct trace_seq *s, const char *str)
187 211
188int trace_seq_putc(struct trace_seq *s, unsigned char c) 212int trace_seq_putc(struct trace_seq *s, unsigned char c)
189{ 213{
190 TRACE_SEQ_CHECK(s); 214 TRACE_SEQ_CHECK_RET0(s);
191 215
192 while (s->len >= (s->buffer_size - 1)) 216 while (s->len >= (s->buffer_size - 1))
193 expand_buffer(s); 217 expand_buffer(s);
194 218
219 TRACE_SEQ_CHECK_RET0(s);
220
195 s->buffer[s->len++] = c; 221 s->buffer[s->len++] = c;
196 222
197 return 1; 223 return 1;
@@ -199,7 +225,7 @@ int trace_seq_putc(struct trace_seq *s, unsigned char c)
199 225
200void trace_seq_terminate(struct trace_seq *s) 226void trace_seq_terminate(struct trace_seq *s)
201{ 227{
202 TRACE_SEQ_CHECK(s); 228 TRACE_SEQ_CHECK_RET(s);
203 229
204 /* There's always one character left on the buffer */ 230 /* There's always one character left on the buffer */
205 s->buffer[s->len] = 0; 231 s->buffer[s->len] = 0;
@@ -208,5 +234,16 @@ void trace_seq_terminate(struct trace_seq *s)
208int trace_seq_do_printf(struct trace_seq *s) 234int trace_seq_do_printf(struct trace_seq *s)
209{ 235{
210 TRACE_SEQ_CHECK(s); 236 TRACE_SEQ_CHECK(s);
211 return printf("%.*s", s->len, s->buffer); 237
238 switch (s->state) {
239 case TRACE_SEQ__GOOD:
240 return printf("%.*s", s->len, s->buffer);
241 case TRACE_SEQ__BUFFER_POISONED:
242 puts("Usage of trace_seq after it was destroyed");
243 break;
244 case TRACE_SEQ__MEM_ALLOC_FAILED:
245 puts("Can't allocate trace_seq buffer memory");
246 break;
247 }
248 return -1;
212} 249}
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 82bffac036e1..c71b0f36d9e8 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -68,8 +68,7 @@ OPTIONS
68--realtime=:: 68--realtime=::
69 Collect data with this RT SCHED_FIFO priority. 69 Collect data with this RT SCHED_FIFO priority.
70 70
71-D:: 71--no-buffering::
72--no-delay::
73 Collect data without buffering. 72 Collect data without buffering.
74 73
75-c:: 74-c::
@@ -209,7 +208,8 @@ overrides that and uses per-thread mmaps. A side-effect of that is that
209inheritance is automatically disabled. --per-thread is ignored with a warning 208inheritance is automatically disabled. --per-thread is ignored with a warning
210if combined with -a or -C options. 209if combined with -a or -C options.
211 210
212--initial-delay msecs:: 211-D::
212--delay=::
213After starting the program, wait msecs before measuring. This is useful to 213After starting the program, wait msecs before measuring. This is useful to
214filter out the startup phase of the program, which is often very different. 214filter out the startup phase of the program, which is often very different.
215 215
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 87d7726cee2d..7257e7e9e38a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -76,6 +76,7 @@ $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
76 76
77CC = $(CROSS_COMPILE)gcc 77CC = $(CROSS_COMPILE)gcc
78AR = $(CROSS_COMPILE)ar 78AR = $(CROSS_COMPILE)ar
79PKG_CONFIG = $(CROSS_COMPILE)pkg-config
79 80
80RM = rm -f 81RM = rm -f
81LN = ln -f 82LN = ln -f
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 07d4cf8d3fd3..3c394bf16fa8 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -838,7 +838,7 @@ const struct option record_options[] = {
838 "record events on existing thread id"), 838 "record events on existing thread id"),
839 OPT_INTEGER('r', "realtime", &record.realtime_prio, 839 OPT_INTEGER('r', "realtime", &record.realtime_prio,
840 "collect data with this RT SCHED_FIFO priority"), 840 "collect data with this RT SCHED_FIFO priority"),
841 OPT_BOOLEAN('D', "no-delay", &record.opts.no_delay, 841 OPT_BOOLEAN(0, "no-buffering", &record.opts.no_buffering,
842 "collect data without buffering"), 842 "collect data without buffering"),
843 OPT_BOOLEAN('R', "raw-samples", &record.opts.raw_samples, 843 OPT_BOOLEAN('R', "raw-samples", &record.opts.raw_samples,
844 "collect raw sample records from all opened counters"), 844 "collect raw sample records from all opened counters"),
@@ -882,7 +882,7 @@ const struct option record_options[] = {
882 OPT_CALLBACK('G', "cgroup", &record.evlist, "name", 882 OPT_CALLBACK('G', "cgroup", &record.evlist, "name",
883 "monitor event in cgroup name only", 883 "monitor event in cgroup name only",
884 parse_cgroups), 884 parse_cgroups),
885 OPT_UINTEGER(0, "initial-delay", &record.opts.initial_delay, 885 OPT_UINTEGER('D', "delay", &record.opts.initial_delay,
886 "ms to wait before starting measurement after program start"), 886 "ms to wait before starting measurement after program start"),
887 OPT_STRING('u', "uid", &record.opts.target.uid_str, "user", 887 OPT_STRING('u', "uid", &record.opts.target.uid_str, "user",
888 "user to profile"), 888 "user to profile"),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 46864dd7eb83..3c53ec268fbc 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -75,24 +75,6 @@ static int report__config(const char *var, const char *value, void *cb)
75 return perf_default_config(var, value, cb); 75 return perf_default_config(var, value, cb);
76} 76}
77 77
78static int report__resolve_callchain(struct report *rep, struct symbol **parent,
79 struct perf_evsel *evsel, struct addr_location *al,
80 struct perf_sample *sample)
81{
82 if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
83 return machine__resolve_callchain(al->machine, evsel, al->thread, sample,
84 parent, al, rep->max_stack);
85 }
86 return 0;
87}
88
89static int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample)
90{
91 if (!symbol_conf.use_callchain)
92 return 0;
93 return callchain_append(he->callchain, &callchain_cursor, sample->period);
94}
95
96static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_location *al, 78static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_location *al,
97 struct perf_sample *sample, struct perf_evsel *evsel, 79 struct perf_sample *sample, struct perf_evsel *evsel,
98 union perf_event *event) 80 union perf_event *event)
@@ -103,7 +85,7 @@ static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_locati
103 struct hist_entry *he; 85 struct hist_entry *he;
104 struct mem_info *mi, *mx; 86 struct mem_info *mi, *mx;
105 uint64_t cost; 87 uint64_t cost;
106 int err = report__resolve_callchain(rep, &parent, evsel, al, sample); 88 int err = sample__resolve_callchain(sample, &parent, evsel, al, rep->max_stack);
107 89
108 if (err) 90 if (err)
109 return err; 91 return err;
@@ -155,7 +137,7 @@ static int report__add_branch_hist_entry(struct perf_tool *tool, struct addr_loc
155 unsigned i; 137 unsigned i;
156 struct hist_entry *he; 138 struct hist_entry *he;
157 struct branch_info *bi, *bx; 139 struct branch_info *bi, *bx;
158 int err = report__resolve_callchain(rep, &parent, evsel, al, sample); 140 int err = sample__resolve_callchain(sample, &parent, evsel, al, rep->max_stack);
159 141
160 if (err) 142 if (err)
161 return err; 143 return err;
@@ -208,7 +190,7 @@ static int report__add_hist_entry(struct perf_tool *tool, struct perf_evsel *evs
208 struct report *rep = container_of(tool, struct report, tool); 190 struct report *rep = container_of(tool, struct report, tool);
209 struct symbol *parent = NULL; 191 struct symbol *parent = NULL;
210 struct hist_entry *he; 192 struct hist_entry *he;
211 int err = report__resolve_callchain(rep, &parent, evsel, al, sample); 193 int err = sample__resolve_callchain(sample, &parent, evsel, al, rep->max_stack);
212 194
213 if (err) 195 if (err)
214 return err; 196 return err;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 569dd87690ef..76cd510d34d0 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -743,15 +743,10 @@ static void perf_event__process_sample(struct perf_tool *tool,
743 if (al.sym == NULL || !al.sym->ignore) { 743 if (al.sym == NULL || !al.sym->ignore) {
744 struct hist_entry *he; 744 struct hist_entry *he;
745 745
746 if ((sort__has_parent || symbol_conf.use_callchain) && 746 err = sample__resolve_callchain(sample, &parent, evsel, &al,
747 sample->callchain) { 747 top->max_stack);
748 err = machine__resolve_callchain(machine, evsel, 748 if (err)
749 al.thread, sample, 749 return;
750 &parent, &al,
751 top->max_stack);
752 if (err)
753 return;
754 }
755 750
756 he = perf_evsel__add_hist_entry(evsel, &al, sample); 751 he = perf_evsel__add_hist_entry(evsel, &al, sample);
757 if (he == NULL) { 752 if (he == NULL) {
@@ -759,12 +754,9 @@ static void perf_event__process_sample(struct perf_tool *tool,
759 return; 754 return;
760 } 755 }
761 756
762 if (symbol_conf.use_callchain) { 757 err = hist_entry__append_callchain(he, sample);
763 err = callchain_append(he->callchain, &callchain_cursor, 758 if (err)
764 sample->period); 759 return;
765 if (err)
766 return;
767 }
768 760
769 if (sort__has_sym) 761 if (sort__has_sym)
770 perf_top__record_precise_ip(top, he, evsel->idx, ip); 762 perf_top__record_precise_ip(top, he, evsel->idx, ip);
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4bd44aba343e..896f27047ed6 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2258,7 +2258,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
2258 }, 2258 },
2259 .user_freq = UINT_MAX, 2259 .user_freq = UINT_MAX,
2260 .user_interval = ULLONG_MAX, 2260 .user_interval = ULLONG_MAX,
2261 .no_delay = true, 2261 .no_buffering = true,
2262 .mmap_pages = 1024, 2262 .mmap_pages = 1024,
2263 }, 2263 },
2264 .output = stdout, 2264 .output = stdout,
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 01dd43df0d04..d604e50fc167 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -372,7 +372,7 @@ ifndef NO_SLANG
372endif 372endif
373 373
374ifndef NO_GTK2 374ifndef NO_GTK2
375 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) 375 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
376 ifneq ($(feature-gtk2), 1) 376 ifneq ($(feature-gtk2), 1)
377 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); 377 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
378 NO_GTK2 := 1 378 NO_GTK2 := 1
@@ -381,8 +381,8 @@ ifndef NO_GTK2
381 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT 381 GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
382 endif 382 endif
383 CFLAGS += -DHAVE_GTK2_SUPPORT 383 CFLAGS += -DHAVE_GTK2_SUPPORT
384 GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) 384 GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
385 GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null) 385 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
386 EXTLIBS += -ldl 386 EXTLIBS += -ldl
387 endif 387 endif
388endif 388endif
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 7cf6fcdacebe..12e551346fa6 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -28,7 +28,8 @@ FILES= \
28 test-stackprotector-all.bin \ 28 test-stackprotector-all.bin \
29 test-timerfd.bin 29 test-timerfd.bin
30 30
31CC := $(CC) -MD 31CC := $(CROSS_COMPILE)gcc -MD
32PKG_CONFIG := $(CROSS_COMPILE)pkg-config
32 33
33all: $(FILES) 34all: $(FILES)
34 35
@@ -37,7 +38,7 @@ BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
37############################### 38###############################
38 39
39test-all.bin: 40test-all.bin:
40 $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl 41 $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
41 42
42test-hello.bin: 43test-hello.bin:
43 $(BUILD) 44 $(BUILD)
@@ -82,10 +83,10 @@ test-libslang.bin:
82 $(BUILD) -I/usr/include/slang -lslang 83 $(BUILD) -I/usr/include/slang -lslang
83 84
84test-gtk2.bin: 85test-gtk2.bin:
85 $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) 86 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
86 87
87test-gtk2-infobar.bin: 88test-gtk2-infobar.bin:
88 $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) 89 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
89 90
90grep-libs = $(filter -l%,$(1)) 91grep-libs = $(filter -l%,$(1))
91strip-libs = $(filter-out -l%,$(1)) 92strip-libs = $(filter-out -l%,$(1))
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index af1ce6e14a93..3c2f213e979d 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -252,7 +252,7 @@ struct record_opts {
252 int call_graph; 252 int call_graph;
253 bool group; 253 bool group;
254 bool inherit_stat; 254 bool inherit_stat;
255 bool no_delay; 255 bool no_buffering;
256 bool no_inherit; 256 bool no_inherit;
257 bool no_inherit_set; 257 bool no_inherit_set;
258 bool no_samples; 258 bool no_samples;
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c
index 5a016f66f5d2..c505ef2af245 100644
--- a/tools/perf/tests/open-syscall-tp-fields.c
+++ b/tools/perf/tests/open-syscall-tp-fields.c
@@ -11,10 +11,10 @@ int test__syscall_open_tp_fields(void)
11 .uid = UINT_MAX, 11 .uid = UINT_MAX,
12 .uses_mmap = true, 12 .uses_mmap = true,
13 }, 13 },
14 .no_delay = true, 14 .no_buffering = true,
15 .freq = 1, 15 .freq = 1,
16 .mmap_pages = 256, 16 .mmap_pages = 256,
17 .raw_samples = true, 17 .raw_samples = true,
18 }; 18 };
19 const char *filename = "/etc/passwd"; 19 const char *filename = "/etc/passwd";
20 int flags = O_RDONLY | O_DIRECTORY; 20 int flags = O_RDONLY | O_DIRECTORY;
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 39cc7c3c0d0c..aca1a83dd13a 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -39,9 +39,9 @@ int test__PERF_RECORD(void)
39 .uid = UINT_MAX, 39 .uid = UINT_MAX,
40 .uses_mmap = true, 40 .uses_mmap = true,
41 }, 41 },
42 .no_delay = true, 42 .no_buffering = true,
43 .freq = 10, 43 .freq = 10,
44 .mmap_pages = 256, 44 .mmap_pages = 256,
45 }; 45 };
46 cpu_set_t cpu_mask; 46 cpu_set_t cpu_mask;
47 size_t cpu_mask_size = sizeof(cpu_mask); 47 size_t cpu_mask_size = sizeof(cpu_mask);
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index e3970e3eaacf..9eb4f57f8663 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -17,6 +17,8 @@
17 17
18#include "hist.h" 18#include "hist.h"
19#include "util.h" 19#include "util.h"
20#include "sort.h"
21#include "machine.h"
20#include "callchain.h" 22#include "callchain.h"
21 23
22__thread struct callchain_cursor callchain_cursor; 24__thread struct callchain_cursor callchain_cursor;
@@ -531,3 +533,24 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
531 533
532 return 0; 534 return 0;
533} 535}
536
537int sample__resolve_callchain(struct perf_sample *sample, struct symbol **parent,
538 struct perf_evsel *evsel, struct addr_location *al,
539 int max_stack)
540{
541 if (sample->callchain == NULL)
542 return 0;
543
544 if (symbol_conf.use_callchain || sort__has_parent) {
545 return machine__resolve_callchain(al->machine, evsel, al->thread,
546 sample, parent, al, max_stack);
547 }
548 return 0;
549}
550
551int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample)
552{
553 if (!symbol_conf.use_callchain)
554 return 0;
555 return callchain_append(he->callchain, &callchain_cursor, sample->period);
556}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 08b25af9eea1..8ad97e9b119f 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -145,10 +145,16 @@ static inline void callchain_cursor_advance(struct callchain_cursor *cursor)
145} 145}
146 146
147struct option; 147struct option;
148struct hist_entry;
148 149
149int record_parse_callchain(const char *arg, struct record_opts *opts); 150int record_parse_callchain(const char *arg, struct record_opts *opts);
150int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset); 151int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset);
151int record_callchain_opt(const struct option *opt, const char *arg, int unset); 152int record_callchain_opt(const struct option *opt, const char *arg, int unset);
152 153
154int sample__resolve_callchain(struct perf_sample *sample, struct symbol **parent,
155 struct perf_evsel *evsel, struct addr_location *al,
156 int max_stack);
157int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample);
158
153extern const char record_callchain_help[]; 159extern const char record_callchain_help[];
154#endif /* __PERF_CALLCHAIN_H */ 160#endif /* __PERF_CALLCHAIN_H */
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index cd4630abfa43..22e18a26b7e6 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -627,7 +627,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
627 if (opts->sample_address) 627 if (opts->sample_address)
628 perf_evsel__set_sample_bit(evsel, DATA_SRC); 628 perf_evsel__set_sample_bit(evsel, DATA_SRC);
629 629
630 if (opts->no_delay) { 630 if (opts->no_buffering) {
631 attr->watermark = 0; 631 attr->watermark = 0;
632 attr->wakeup_events = 1; 632 attr->wakeup_events = 1;
633 } 633 }
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 4ed3e883240d..e4e6249b87d4 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -181,21 +181,21 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows)
181 } 181 }
182} 182}
183 183
184static void hist_entry__add_cpumode_period(struct hist_entry *he, 184static void he_stat__add_cpumode_period(struct he_stat *he_stat,
185 unsigned int cpumode, u64 period) 185 unsigned int cpumode, u64 period)
186{ 186{
187 switch (cpumode) { 187 switch (cpumode) {
188 case PERF_RECORD_MISC_KERNEL: 188 case PERF_RECORD_MISC_KERNEL:
189 he->stat.period_sys += period; 189 he_stat->period_sys += period;
190 break; 190 break;
191 case PERF_RECORD_MISC_USER: 191 case PERF_RECORD_MISC_USER:
192 he->stat.period_us += period; 192 he_stat->period_us += period;
193 break; 193 break;
194 case PERF_RECORD_MISC_GUEST_KERNEL: 194 case PERF_RECORD_MISC_GUEST_KERNEL:
195 he->stat.period_guest_sys += period; 195 he_stat->period_guest_sys += period;
196 break; 196 break;
197 case PERF_RECORD_MISC_GUEST_USER: 197 case PERF_RECORD_MISC_GUEST_USER:
198 he->stat.period_guest_us += period; 198 he_stat->period_guest_us += period;
199 break; 199 break;
200 default: 200 default:
201 break; 201 break;
@@ -222,10 +222,10 @@ static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
222 dest->weight += src->weight; 222 dest->weight += src->weight;
223} 223}
224 224
225static void hist_entry__decay(struct hist_entry *he) 225static void he_stat__decay(struct he_stat *he_stat)
226{ 226{
227 he->stat.period = (he->stat.period * 7) / 8; 227 he_stat->period = (he_stat->period * 7) / 8;
228 he->stat.nr_events = (he->stat.nr_events * 7) / 8; 228 he_stat->nr_events = (he_stat->nr_events * 7) / 8;
229 /* XXX need decay for weight too? */ 229 /* XXX need decay for weight too? */
230} 230}
231 231
@@ -236,7 +236,7 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
236 if (prev_period == 0) 236 if (prev_period == 0)
237 return true; 237 return true;
238 238
239 hist_entry__decay(he); 239 he_stat__decay(&he->stat);
240 240
241 if (!he->filtered) 241 if (!he->filtered)
242 hists->stats.total_period -= prev_period - he->stat.period; 242 hists->stats.total_period -= prev_period - he->stat.period;
@@ -402,7 +402,7 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
402 rb_link_node(&he->rb_node_in, parent, p); 402 rb_link_node(&he->rb_node_in, parent, p);
403 rb_insert_color(&he->rb_node_in, hists->entries_in); 403 rb_insert_color(&he->rb_node_in, hists->entries_in);
404out: 404out:
405 hist_entry__add_cpumode_period(he, al->cpumode, period); 405 he_stat__add_cpumode_period(&he->stat, al->cpumode, period);
406 return he; 406 return he;
407} 407}
408 408
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 0130279aac51..ded74590b92f 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1314,8 +1314,6 @@ static int machine__resolve_callchain_sample(struct machine *machine,
1314 *root_al = al; 1314 *root_al = al;
1315 callchain_cursor_reset(&callchain_cursor); 1315 callchain_cursor_reset(&callchain_cursor);
1316 } 1316 }
1317 if (!symbol_conf.use_callchain)
1318 break;
1319 } 1317 }
1320 1318
1321 err = callchain_cursor_append(&callchain_cursor, 1319 err = callchain_cursor_append(&callchain_cursor,
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 7e67879ebd25..f3e4bc5fe5d2 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -129,7 +129,7 @@ static struct a2l_data *addr2line_init(const char *path)
129 129
130out: 130out:
131 if (a2l) { 131 if (a2l) {
132 zfree((void **)&a2l->input); 132 zfree((char **)&a2l->input);
133 free(a2l); 133 free(a2l);
134 } 134 }
135 bfd_close(abfd); 135 bfd_close(abfd);
@@ -140,7 +140,7 @@ static void addr2line_cleanup(struct a2l_data *a2l)
140{ 140{
141 if (a2l->abfd) 141 if (a2l->abfd)
142 bfd_close(a2l->abfd); 142 bfd_close(a2l->abfd);
143 zfree((void **)&a2l->input); 143 zfree((char **)&a2l->input);
144 zfree(&a2l->syms); 144 zfree(&a2l->syms);
145 free(a2l); 145 free(a2l);
146} 146}
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index 61a90bf24b4d..71f9d102b96f 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -39,7 +39,7 @@ out_delete:
39static void str_node__delete(struct str_node *snode, bool dupstr) 39static void str_node__delete(struct str_node *snode, bool dupstr)
40{ 40{
41 if (dupstr) 41 if (dupstr)
42 zfree((void **)&snode->s); 42 zfree((char **)&snode->s);
43 free(snode); 43 free(snode);
44} 44}
45 45
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index d9f5f6137ab3..6322d37164c5 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -34,8 +34,8 @@ int trace_event__init(struct trace_event *t)
34 34
35void trace_event__cleanup(struct trace_event *t) 35void trace_event__cleanup(struct trace_event *t)
36{ 36{
37 traceevent_unload_plugins(t->plugin_list, t->pevent);
37 pevent_free(t->pevent); 38 pevent_free(t->pevent);
38 traceevent_unload_plugins(t->plugin_list);
39} 39}
40 40
41static struct event_format* 41static struct event_format*