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
7#undef TRACE_SYSTEM7#undef TRACE_SYSTEM
8#define TRACE_SYSTEM irq8#define TRACE_SYSTEM irq
9 9
10#define softirq_name(sirq) { sirq, #sirq }10#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
11#define show_softirq_name(val) \11#define show_softirq_name(val) \
12 __print_symbolic(val, \12 __print_symbolic(val, \
13 softirq_name(HI_SOFTIRQ), \13 softirq_name(HI), \
14 softirq_name(TIMER_SOFTIRQ), \14 softirq_name(TIMER), \
15 softirq_name(NET_TX_SOFTIRQ), \15 softirq_name(NET_TX), \
16 softirq_name(NET_RX_SOFTIRQ), \16 softirq_name(NET_RX), \
17 softirq_name(BLOCK_SOFTIRQ), \17 softirq_name(BLOCK), \
18 softirq_name(TASKLET_SOFTIRQ), \18 softirq_name(TASKLET), \
19 softirq_name(SCHED_SOFTIRQ), \19 softirq_name(SCHED), \
20 softirq_name(HRTIMER_SOFTIRQ), \20 softirq_name(HRTIMER), \
21 softirq_name(RCU_SOFTIRQ))21 softirq_name(RCU))
22 22
23/**23/**
24 * irq_handler_entry - called immediately before the irq action handler24 * irq_handler_entry - called immediately before the irq action handler
include/trace/ftrace.h+90−36
@@ -18,14 +18,17 @@ · 17 unmodified lines
18 18
19#include <linux/ftrace_event.h>19#include <linux/ftrace_event.h>
20 20
21#undef __field
22#define __field(type, item) type item;
23
21#undef __array24#undef __array
22#define __array(type, item, len) type item[len];25#define __array(type, item, len) type item[len];
23 26
24#undef __field27#undef __dynamic_array
25#define __field(type, item) type item;28#define __dynamic_array(type, item, len) unsigned short __data_loc_##item;
26 29
27#undef __string30#undef __string
28#define __string(item, src) unsigned short __str_loc_##item;31#define __string(item, src) __dynamic_array(char, item, -1)
29 32
30#undef TP_STRUCT__entry33#undef TP_STRUCT__entry
31#define TP_STRUCT__entry(args...) args34#define TP_STRUCT__entry(args...) args
@@ -35,7 +38,7 @@ · 3 unmodified lines
35 struct ftrace_raw_##name { \38 struct ftrace_raw_##name { \
36 struct trace_entry ent; \39 struct trace_entry ent; \
37 tstruct \40 tstruct \
38 char __str_data[0]; \41 char __data[0]; \
39 }; \42 }; \
40 static struct ftrace_event_call event_##name43 static struct ftrace_event_call event_##name
41 44
@@ -47,30 +50,31 @@ · 5 unmodified lines
47 *50 *
48 * Include the following:51 * Include the following:
49 *52 *
50 * struct ftrace_str_offsets_<call> {53 * struct ftrace_data_offsets_<call> {
51 * int <str1>;54 * int <item1>;
52 * int <str2>;55 * int <item2>;
53 * [...]56 * [...]
54 * };57 * };
55 *58 *
56 * The __string() macro will create each int <str>, this is to59 * The __dynamic_array() macro will create each int <item>, this is
57 * keep the offset of each string from the beggining of the event60 * to keep the offset of each array from the beginning of the event.
58 * once we perform the strlen() of the src strings.
59 *
60 */61 */
61 62
63#undef __field
64#define __field(type, item);
65
62#undef __array66#undef __array
63#define __array(type, item, len)67#define __array(type, item, len)
64 68
65#undef __field69#undef __dynamic_array
66#define __field(type, item);70#define __dynamic_array(type, item, len) int item;
67 71
68#undef __string72#undef __string
69#define __string(item, src) int item;73#define __string(item, src) __dynamic_array(char, item, -1)
70 74
71#undef TRACE_EVENT75#undef TRACE_EVENT
72#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \76#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
73 struct ftrace_str_offsets_##call { \77 struct ftrace_data_offsets_##call { \
74 tstruct; \78 tstruct; \
75 };79 };
76 80
@@ -119,8 +123,12 @@ · 42 unmodified lines
119#undef TP_printk123#undef TP_printk
120#define TP_printk(fmt, args...) fmt "\n", args124#define TP_printk(fmt, args...) fmt "\n", args
121 125
126#undef __get_dynamic_array
127#define __get_dynamic_array(field) \
128 ((void *)__entry + __entry->__data_loc_##field)
129
122#undef __get_str130#undef __get_str
123#define __get_str(field) ((char *)__entry + __entry->__str_loc_##field)131#define __get_str(field) (char *)__get_dynamic_array(field)
124 132
125#undef __print_flags133#undef __print_flags
126#define __print_flags(flag, delim, flag_array...) \134#define __print_flags(flag, delim, flag_array...) \
@@ -207,16 +215,19 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ · 80 unmodified lines
207 if (!ret) \215 if (!ret) \
208 return 0;216 return 0;
209 217
210#undef __string218#undef __dynamic_array
211#define __string(item, src) \219#define __dynamic_array(type, item, len) \
212 ret = trace_seq_printf(s, "\tfield: __str_loc " #item ";\t" \220 ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \
213 "offset:%u;tsize:%u;\n", \221 "offset:%u;\tsize:%u;\n", \
214 (unsigned int)offsetof(typeof(field), \222 (unsigned int)offsetof(typeof(field), \
215 __str_loc_##item), \223 __data_loc_##item), \
216 (unsigned int)sizeof(field.__str_loc_##item)); \224 (unsigned int)sizeof(field.__data_loc_##item)); \
217 if (!ret) \225 if (!ret) \
218 return 0;226 return 0;
219 227
228#undef __string
229#define __string(item, src) __dynamic_array(char, item, -1)
230
220#undef __entry231#undef __entry
221#define __entry REC232#define __entry REC
222 233
@@ -260,11 +271,14 @@ ftrace_format_##call(struct trace_seq *s) \ · 37 unmodified lines
260 if (ret) \271 if (ret) \
261 return ret;272 return ret;
262 273
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
263#undef __string280#undef __string
264#define __string(item, src) \281#define __string(item, src) __dynamic_array(char, item, -1)
265 ret = trace_define_field(event_call, "__str_loc", #item, \
266 offsetof(typeof(field), __str_loc_##item), \
267 sizeof(field.__str_loc_##item), 0);
268 282
269#undef TRACE_EVENT283#undef TRACE_EVENT
270#define TRACE_EVENT(call, proto, args, tstruct, func, print) \284#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
@@ -288,6 +302,43 @@ ftrace_define_fields_##call(void) \ · 17 unmodified lines
288 302
289#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)303#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
290 304
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) \
329static 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
291/*342/*
292 * Stage 4 of the trace events.343 * Stage 4 of the trace events.
293 *344 *
@@ -432,15 +483,15 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ · 138 unmodified lines
432#undef __array483#undef __array
433#define __array(type, item, len)484#define __array(type, item, len)
434 485
486#undef __dynamic_array
487#define __dynamic_array(type, item, len) \
488 __entry->__data_loc_##item = __data_offsets.item;
489
435#undef __string490#undef __string
436#define __string(item, src) \491#define __string(item, src) __dynamic_array(char, item, -1) \
437 __str_offsets.item = __str_size + \
438 offsetof(typeof(*entry), __str_data); \
439 __str_size += strlen(src) + 1;
440 492
441#undef __assign_str493#undef __assign_str
442#define __assign_str(dst, src) \494#define __assign_str(dst, src) \
443 __entry->__str_loc_##dst = __str_offsets.dst; \
444 strcpy(__get_str(dst), src);495 strcpy(__get_str(dst), src);
445 496
446#undef TRACE_EVENT497#undef TRACE_EVENT
@@ -451,27 +502,30 @@ static struct ftrace_event_call event_##call; \ · 4 unmodified lines
451 \502 \
452static void ftrace_raw_event_##call(proto) \503static void ftrace_raw_event_##call(proto) \
453{ \504{ \
454 struct ftrace_str_offsets_##call __maybe_unused __str_offsets; \505 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
455 struct ftrace_event_call *event_call = &event_##call; \506 struct ftrace_event_call *event_call = &event_##call; \
456 struct ring_buffer_event *event; \507 struct ring_buffer_event *event; \
457 struct ftrace_raw_##call *entry; \508 struct ftrace_raw_##call *entry; \
458 unsigned long irq_flags; \509 unsigned long irq_flags; \
459 int __str_size = 0; \510 int __data_size; \
460 int pc; \511 int pc; \
461 \512 \
462 local_save_flags(irq_flags); \513 local_save_flags(irq_flags); \
463 pc = preempt_count(); \514 pc = preempt_count(); \
464 \515 \
465 tstruct; \516 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
466 \517 \
467 event = trace_current_buffer_lock_reserve(event_##call.id, \518 event = trace_current_buffer_lock_reserve(event_##call.id, \
468 sizeof(struct ftrace_raw_##call) + __str_size,\519 sizeof(*entry) + __data_size, \
469 irq_flags, pc); \520 irq_flags, pc); \
470 if (!event) \521 if (!event) \
471 return; \522 return; \
472 entry = ring_buffer_event_data(event); \523 entry = ring_buffer_event_data(event); \
473 \524 \
474 assign; \525 \
526 tstruct \
527 \
528 { assign; } \
475 \529 \
476 if (!filter_current_check_discard(event_call, entry, event)) \530 if (!filter_current_check_discard(event_call, entry, event)) \
477 trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \531 trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \