aboutsummaryrefslogtreecommitdiffstats
path: root/include/trace
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2014-03-01 00:32:17 -0500
committerSteven Rostedt <rostedt@goodmis.org>2014-03-07 10:06:11 -0500
commit114e7b52dee69ce47dd55b8e520e0a48ba7cdae3 (patch)
treed7ac31acb21d9427f0bbf87cd9b17c41b8df370b /include/trace
parent5859fa1a146ef5bf79953767f4ceb546fe4214b3 (diff)
tracing: Evaluate len expression only once in __dynamic_array macro
Use a temporary variable to store the expansion of the len expression. If the evaluation is expensive, this commit will ensure it is evaluated only once inside ftrace_get_offsets_<call>. Link: http://lkml.kernel.org/r/1393651938-16418-3-git-send-email-filbranden@google.com Signed-off-by: Filipe Brandenburger <filbranden@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/trace')
-rw-r--r--include/trace/ftrace.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 21250056b7da..e15ae4010d51 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -361,10 +361,11 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
361 361
362#undef __dynamic_array 362#undef __dynamic_array
363#define __dynamic_array(type, item, len) \ 363#define __dynamic_array(type, item, len) \
364 __item_length = (len) * sizeof(type); \
364 __data_offsets->item = __data_size + \ 365 __data_offsets->item = __data_size + \
365 offsetof(typeof(*entry), __data); \ 366 offsetof(typeof(*entry), __data); \
366 __data_offsets->item |= ((len) * sizeof(type)) << 16; \ 367 __data_offsets->item |= __item_length << 16; \
367 __data_size += (len) * sizeof(type); 368 __data_size += __item_length;
368 369
369#undef __string 370#undef __string
370#define __string(item, src) __dynamic_array(char, item, \ 371#define __string(item, src) __dynamic_array(char, item, \
@@ -376,6 +377,7 @@ static inline notrace int ftrace_get_offsets_##call( \
376 struct ftrace_data_offsets_##call *__data_offsets, proto) \ 377 struct ftrace_data_offsets_##call *__data_offsets, proto) \
377{ \ 378{ \
378 int __data_size = 0; \ 379 int __data_size = 0; \
380 int __maybe_unused __item_length; \
379 struct ftrace_raw_##call __maybe_unused *entry; \ 381 struct ftrace_raw_##call __maybe_unused *entry; \
380 \ 382 \
381 tstruct; \ 383 tstruct; \