History

Merge branch 'tracing/ftrace' into tracing/core

Merge reason: this mini-topic had outstanding problems that delayed its merge, so it does not fast-forward.

Ingo Molnar committed 17 years ago

Commit 64edbc52 parents 43bd123 0f6ce3d9 files · +205 −86Browse files

Showing the changes to include/trace (2 of 9 files). Show all

Unified · Split

2 files
  1. include/trace/events/irq.h +12 −12
  2. include/trace/ftrace.h +90 −36
include/trace/events/irq.h+12−12
@@ -7,18 +7,18 @@ · 6 unmodified lines
77 #undef TRACE_SYSTEM
88 #define TRACE_SYSTEM irq
99
10−#define softirq_name(sirq) { sirq, #sirq }
11−#define show_softirq_name(val) \
12− __print_symbolic(val, \
13− softirq_name(HI_SOFTIRQ), \
14− softirq_name(TIMER_SOFTIRQ), \
15− softirq_name(NET_TX_SOFTIRQ), \
16− softirq_name(NET_RX_SOFTIRQ), \
17− softirq_name(BLOCK_SOFTIRQ), \
18− softirq_name(TASKLET_SOFTIRQ), \
19− softirq_name(SCHED_SOFTIRQ), \
20− softirq_name(HRTIMER_SOFTIRQ), \
21− softirq_name(RCU_SOFTIRQ))
10+#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
11+#define show_softirq_name(val) \
12+ __print_symbolic(val, \
13+ softirq_name(HI), \
14+ softirq_name(TIMER), \
15+ softirq_name(NET_TX), \
16+ softirq_name(NET_RX), \
17+ softirq_name(BLOCK), \
18+ softirq_name(TASKLET), \
19+ softirq_name(SCHED), \
20+ softirq_name(HRTIMER), \
21+ softirq_name(RCU))
2222
2323 /**
2424 * irq_handler_entry - called immediately before the irq action handler
include/trace/ftrace.h+90−36
@@ -18,14 +18,17 @@ · 17 unmodified lines
1818
1919 #include <linux/ftrace_event.h>
2020
21+#undef __field
22+#define __field(type, item) type item;
23+
2124 #undef __array
2225 #define __array(type, item, len) type item[len];
2326
24−#undef __field
25−#define __field(type, item) type item;
27+#undef __dynamic_array
28+#define __dynamic_array(type, item, len) unsigned short __data_loc_##item;
2629
2730 #undef __string
28−#define __string(item, src) unsigned short __str_loc_##item;
31+#define __string(item, src) __dynamic_array(char, item, -1)
2932
3033 #undef TP_STRUCT__entry
3134 #define TP_STRUCT__entry(args...) args
@@ -35,7 +38,7 @@ · 3 unmodified lines
3538 struct ftrace_raw_##name { \
3639 struct trace_entry ent; \
3740 tstruct \
38− char __str_data[0]; \
41+ char __data[0]; \
3942 }; \
4043 static struct ftrace_event_call event_##name
4144
@@ -47,30 +50,31 @@ · 5 unmodified lines
4750 *
4851 * Include the following:
4952 *
50− * struct ftrace_str_offsets_<call> {
51− * int <str1>;
52− * int <str2>;
53+ * struct ftrace_data_offsets_<call> {
54+ * int <item1>;
55+ * int <item2>;
5356 * [...]
5457 * };
5558 *
56− * The __string() macro will create each int <str>, this is to
57− * keep the offset of each string from the beggining of the event
58− * once we perform the strlen() of the src strings.
59− *
59+ * The __dynamic_array() macro will create each int <item>, this is
60+ * to keep the offset of each array from the beginning of the event.
6061 */
6162
63+#undef __field
64+#define __field(type, item);
65+
6266 #undef __array
6367 #define __array(type, item, len)
6468
65−#undef __field
66−#define __field(type, item);
69+#undef __dynamic_array
70+#define __dynamic_array(type, item, len) int item;
6771
6872 #undef __string
69−#define __string(item, src) int item;
73+#define __string(item, src) __dynamic_array(char, item, -1)
7074
7175 #undef TRACE_EVENT
7276 #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
73− struct ftrace_str_offsets_##call { \
77+ struct ftrace_data_offsets_##call { \
7478 tstruct; \
7579 };
7680
@@ -119,8 +123,12 @@ · 42 unmodified lines
119123 #undef TP_printk
120124 #define TP_printk(fmt, args...) fmt "\n", args
121125
126+#undef __get_dynamic_array
127+#define __get_dynamic_array(field) \
128+ ((void *)__entry + __entry->__data_loc_##field)
129+
122130 #undef __get_str
123−#define __get_str(field) ((char *)__entry + __entry->__str_loc_##field)
131+#define __get_str(field) (char *)__get_dynamic_array(field)
124132
125133 #undef __print_flags
126134 #define __print_flags(flag, delim, flag_array...) \
@@ -207,16 +215,19 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ · 80 unmodified lines
207215 if (!ret) \
208216 return 0;
209217
210−#undef __string
211−#define __string(item, src) \
212− ret = trace_seq_printf(s, "\tfield: __str_loc " #item ";\t" \
213− "offset:%u;tsize:%u;\n", \
218+#undef __dynamic_array
219+#define __dynamic_array(type, item, len) \
220+ ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \
221+ "offset:%u;\tsize:%u;\n", \
214222 (unsigned int)offsetof(typeof(field), \
215− __str_loc_##item), \
216− (unsigned int)sizeof(field.__str_loc_##item)); \
223+ __data_loc_##item), \
224+ (unsigned int)sizeof(field.__data_loc_##item)); \
217225 if (!ret) \
218226 return 0;
219227
228+#undef __string
229+#define __string(item, src) __dynamic_array(char, item, -1)
230+
220231 #undef __entry
221232 #define __entry REC
222233
@@ -260,11 +271,14 @@ ftrace_format_##call(struct trace_seq *s) \ · 37 unmodified lines
260271 if (ret) \
261272 return ret;
262273
274+#undef __dynamic_array
275+#define __dynamic_array(type, item, len) \
276+ ret = trace_define_field(event_call, "__data_loc" "[" #type "]", #item,\
277+ offsetof(typeof(field), __data_loc_##item), \
278+ sizeof(field.__data_loc_##item), 0);
279+
263280 #undef __string
264−#define __string(item, src) \
265− ret = trace_define_field(event_call, "__str_loc", #item, \
266− offsetof(typeof(field), __str_loc_##item), \
267− sizeof(field.__str_loc_##item), 0);
281+#define __string(item, src) __dynamic_array(char, item, -1)
268282
269283 #undef TRACE_EVENT
270284 #define TRACE_EVENT(call, proto, args, tstruct, func, print) \
@@ -288,6 +302,43 @@ ftrace_define_fields_##call(void) \ · 17 unmodified lines
288302
289303 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
290304
305+/*
306+ * remember the offset of each array from the beginning of the event.
307+ */
308+
309+#undef __entry
310+#define __entry entry
311+
312+#undef __field
313+#define __field(type, item)
314+
315+#undef __array
316+#define __array(type, item, len)
317+
318+#undef __dynamic_array
319+#define __dynamic_array(type, item, len) \
320+ __data_offsets->item = __data_size + \
321+ offsetof(typeof(*entry), __data); \
322+ __data_size += (len) * sizeof(type);
323+
324+#undef __string
325+#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1) \
326+
327+#undef TRACE_EVENT
328+#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
329+static inline int ftrace_get_offsets_##call( \
330+ struct ftrace_data_offsets_##call *__data_offsets, proto) \
331+{ \
332+ int __data_size = 0; \
333+ struct ftrace_raw_##call __maybe_unused *entry; \
334+ \
335+ tstruct; \
336+ \
337+ return __data_size; \
338+}
339+
340+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
341+
291342 /*
292343 * Stage 4 of the trace events.
293344 *
@@ -432,15 +483,15 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ · 138 unmodified lines
432483 #undef __array
433484 #define __array(type, item, len)
434485
486+#undef __dynamic_array
487+#define __dynamic_array(type, item, len) \
488+ __entry->__data_loc_##item = __data_offsets.item;
489+
435490 #undef __string
436−#define __string(item, src) \
437− __str_offsets.item = __str_size + \
438− offsetof(typeof(*entry), __str_data); \
439− __str_size += strlen(src) + 1;
491+#define __string(item, src) __dynamic_array(char, item, -1) \
440492
441493 #undef __assign_str
442494 #define __assign_str(dst, src) \
443− __entry->__str_loc_##dst = __str_offsets.dst; \
444495 strcpy(__get_str(dst), src);
445496
446497 #undef TRACE_EVENT
@@ -451,27 +502,30 @@ static struct ftrace_event_call event_##call; \ · 4 unmodified lines
451502 \
452503 static void ftrace_raw_event_##call(proto) \
453504 { \
454− struct ftrace_str_offsets_##call __maybe_unused __str_offsets; \
505+ struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
455506 struct ftrace_event_call *event_call = &event_##call; \
456507 struct ring_buffer_event *event; \
457508 struct ftrace_raw_##call *entry; \
458509 unsigned long irq_flags; \
459− int __str_size = 0; \
510+ int __data_size; \
460511 int pc; \
461512 \
462513 local_save_flags(irq_flags); \
463514 pc = preempt_count(); \
464515 \
465− tstruct; \
516+ __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
466517 \
467518 event = trace_current_buffer_lock_reserve(event_##call.id, \
468− sizeof(struct ftrace_raw_##call) + __str_size,\
519+ sizeof(*entry) + __data_size, \
469520 irq_flags, pc); \
470521 if (!event) \
471522 return; \
472523 entry = ring_buffer_event_data(event); \
473524 \
474− assign; \
525+ \
526+ tstruct \
527+ \
528+ { assign; } \
475529 \
476530 if (!filter_current_check_discard(event_call, entry, event)) \
477531 trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \