Skip to content

Commit 9fb6720

Browse files
author
Ingo Molnar
committed
Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into perf/core
2 parents 8c1df40 + 287050d commit 9fb6720

7 files changed

Lines changed: 77 additions & 18 deletions

File tree

‎include/linux/ftrace_event.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ enum {
225225
FILTER_PTR_STRING,
226226
};
227227

228+
#define EVENT_STORAGE_SIZE 128
229+
extern struct mutex event_storage_mutex;
230+
extern char event_storage[EVENT_STORAGE_SIZE];
231+
228232
extern int trace_event_raw_init(struct ftrace_event_call *call);
229233
extern int trace_define_field(struct ftrace_event_call *call, const char *type,
230234
const char *name, int offset, int size,

‎include/linux/tracepoint.h‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
106106

107107
#define TP_PROTO(args...) args
108108
#define TP_ARGS(args...) args
109+
#define TP_CONDITION(args...) args
109110

110111
#ifdef CONFIG_TRACEPOINTS
111112

@@ -119,12 +120,14 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
119120
* as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
120121
* "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
121122
*/
122-
#define __DO_TRACE(tp, proto, args) \
123+
#define __DO_TRACE(tp, proto, args, cond) \
123124
do { \
124125
struct tracepoint_func *it_func_ptr; \
125126
void *it_func; \
126127
void *__data; \
127128
\
129+
if (!(cond)) \
130+
return; \
128131
rcu_read_lock_sched_notrace(); \
129132
it_func_ptr = rcu_dereference_sched((tp)->funcs); \
130133
if (it_func_ptr) { \
@@ -142,7 +145,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
142145
* not add unwanted padding between the beginning of the section and the
143146
* structure. Force alignment to the same alignment as the section start.
144147
*/
145-
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
148+
#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
146149
extern struct tracepoint __tracepoint_##name; \
147150
static inline void trace_##name(proto) \
148151
{ \
@@ -151,7 +154,8 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
151154
do_trace: \
152155
__DO_TRACE(&__tracepoint_##name, \
153156
TP_PROTO(data_proto), \
154-
TP_ARGS(data_args)); \
157+
TP_ARGS(data_args), \
158+
TP_CONDITION(cond)); \
155159
} \
156160
static inline int \
157161
register_trace_##name(void (*probe)(data_proto), void *data) \
@@ -186,7 +190,7 @@ do_trace: \
186190
EXPORT_SYMBOL(__tracepoint_##name)
187191

188192
#else /* !CONFIG_TRACEPOINTS */
189-
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
193+
#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
190194
static inline void trace_##name(proto) \
191195
{ } \
192196
static inline int \
@@ -227,13 +231,18 @@ do_trace: \
227231
* "void *__data, proto" as the callback prototype.
228232
*/
229233
#define DECLARE_TRACE_NOARGS(name) \
230-
__DECLARE_TRACE(name, void, , void *__data, __data)
234+
__DECLARE_TRACE(name, void, , 1, void *__data, __data)
231235

232236
#define DECLARE_TRACE(name, proto, args) \
233-
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
237+
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \
234238
PARAMS(void *__data, proto), \
235239
PARAMS(__data, args))
236240

241+
#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \
242+
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
243+
PARAMS(void *__data, proto), \
244+
PARAMS(__data, args))
245+
237246
#define TRACE_EVENT_FLAGS(event, flag)
238247

239248
#endif /* DECLARE_TRACE */
@@ -349,12 +358,20 @@ do_trace: \
349358
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
350359
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
351360
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
361+
#define DEFINE_EVENT_CONDITION(template, name, proto, \
362+
args, cond) \
363+
DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
364+
PARAMS(args), PARAMS(cond))
352365

353366
#define TRACE_EVENT(name, proto, args, struct, assign, print) \
354367
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
355368
#define TRACE_EVENT_FN(name, proto, args, struct, \
356369
assign, print, reg, unreg) \
357370
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
371+
#define TRACE_EVENT_CONDITION(name, proto, args, cond, \
372+
struct, assign, print) \
373+
DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
374+
PARAMS(args), PARAMS(cond))
358375

359376
#define TRACE_EVENT_FLAGS(event, flag)
360377

‎include/trace/define_trace.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
2727
DEFINE_TRACE(name)
2828

29+
#undef TRACE_EVENT_CONDITION
30+
#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
31+
TRACE_EVENT(name, \
32+
PARAMS(proto), \
33+
PARAMS(args), \
34+
PARAMS(tstruct), \
35+
PARAMS(assign), \
36+
PARAMS(print))
37+
2938
#undef TRACE_EVENT_FN
3039
#define TRACE_EVENT_FN(name, proto, args, tstruct, \
3140
assign, print, reg, unreg) \
@@ -39,6 +48,10 @@
3948
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
4049
DEFINE_TRACE(name)
4150

51+
#undef DEFINE_EVENT_CONDITION
52+
#define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
53+
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
54+
4255
#undef DECLARE_TRACE
4356
#define DECLARE_TRACE(name, proto, args) \
4457
DEFINE_TRACE(name)
@@ -75,9 +88,11 @@
7588

7689
#undef TRACE_EVENT
7790
#undef TRACE_EVENT_FN
91+
#undef TRACE_EVENT_CONDITION
7892
#undef DECLARE_EVENT_CLASS
7993
#undef DEFINE_EVENT
8094
#undef DEFINE_EVENT_PRINT
95+
#undef DEFINE_EVENT_CONDITION
8196
#undef TRACE_HEADER_MULTI_READ
8297
#undef DECLARE_TRACE
8398

‎include/trace/ftrace.h‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,19 @@ static struct trace_event_functions ftrace_event_type_funcs_##call = { \
296296

297297
#undef __array
298298
#define __array(type, item, len) \
299-
BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
300-
ret = trace_define_field(event_call, #type "[" #len "]", #item, \
299+
do { \
300+
mutex_lock(&event_storage_mutex); \
301+
BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
302+
snprintf(event_storage, sizeof(event_storage), \
303+
"%s[%d]", #type, len); \
304+
ret = trace_define_field(event_call, event_storage, #item, \
301305
offsetof(typeof(field), item), \
302306
sizeof(field.item), \
303307
is_signed_type(type), FILTER_OTHER); \
304-
if (ret) \
305-
return ret;
308+
mutex_unlock(&event_storage_mutex); \
309+
if (ret) \
310+
return ret; \
311+
} while (0);
306312

307313
#undef __dynamic_array
308314
#define __dynamic_array(type, item, len) \

‎kernel/trace/trace_events.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727

2828
DEFINE_MUTEX(event_mutex);
2929

30+
DEFINE_MUTEX(event_storage_mutex);
31+
EXPORT_SYMBOL_GPL(event_storage_mutex);
32+
33+
char event_storage[EVENT_STORAGE_SIZE];
34+
EXPORT_SYMBOL_GPL(event_storage);
35+
3036
LIST_HEAD(ftrace_events);
3137
LIST_HEAD(ftrace_common_fields);
3238

‎kernel/trace/trace_export.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ static void __always_unused ____ftrace_check_##name(void) \
8383

8484
#undef __array
8585
#define __array(type, item, len) \
86-
BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
87-
ret = trace_define_field(event_call, #type "[" #len "]", #item, \
86+
do { \
87+
BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
88+
mutex_lock(&event_storage_mutex); \
89+
snprintf(event_storage, sizeof(event_storage), \
90+
"%s[%d]", #type, len); \
91+
ret = trace_define_field(event_call, event_storage, #item, \
8892
offsetof(typeof(field), item), \
8993
sizeof(field.item), \
9094
is_signed_type(type), FILTER_OTHER); \
91-
if (ret) \
92-
return ret;
95+
mutex_unlock(&event_storage_mutex); \
96+
if (ret) \
97+
return ret; \
98+
} while (0);
9399

94100
#undef __array_desc
95101
#define __array_desc(type, container, item, len) \

‎scripts/Makefile.build‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,22 @@ ifdef BUILD_C_RECORDMCOUNT
214214
# The empty.o file is created in the make process in order to determine
215215
# the target endianness and word size. It is made before all other C
216216
# files, including recordmcount.
217-
cmd_record_mcount = if [ $(@) != "scripts/mod/empty.o" ]; then \
218-
$(objtree)/scripts/recordmcount "$(@)"; \
219-
fi;
217+
sub_cmd_record_mcount = \
218+
if [ $(@) != "scripts/mod/empty.o" ]; then \
219+
$(objtree)/scripts/recordmcount "$(@)"; \
220+
fi;
220221
else
221-
cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
222+
sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
222223
"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
223224
"$(if $(CONFIG_64BIT),64,32)" \
224225
"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
225226
"$(LD)" "$(NM)" "$(RM)" "$(MV)" \
226227
"$(if $(part-of-module),1,0)" "$(@)";
227228
endif
229+
cmd_record_mcount = \
230+
if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
231+
$(sub_cmd_record_mcount) \
232+
fi;
228233
endif
229234

230235
define rule_cc_o_c

0 commit comments

Comments
 (0)