History

ftrace: Rework event_create_dir()

Rework event_create_dir() to use an array of static data instead of function pointers where possible. The problem is that it would call the function pointer on module load before parse_args(), possibly even before jump_labels were initialized. Luckily the generated functions don't use jump_labels but it still seems fragile. It also gets in the way of changing when we make the module map executable. The generated function are basically calling trace_define_field() with a bunch of static arguments. So instead of a function, capture these arguments in a static array, avoiding the function call. Now there are a number of cases where the fields are dynamic (syscall arguments, kprobes and uprobes), in which case a static array does not work, for these we preserve the function call. Luckily all these cases are not related to modules and so we can retain the function call for them. Also fix up all broken tracepoint definitions that now generate a compile error.

Peter Zijlstra committed 7 years ago

Commit 04ae87a1 parent 958de6621 files · +213 −249Browse files

Unified · Split

21 files
  1. drivers/infiniband/hw/hfi1/trace_tid.h +4 −4
  2. drivers/infiniband/hw/hfi1/trace_tx.h +1 −1
  3. drivers/lightnvm/pblk-trace.h +4 −4
  4. drivers/net/fjes/fjes_trace.h +1 −1
  5. drivers/net/wireless/ath/ath10k/trace.h +3 −3
  6. fs/xfs/scrub/trace.h +3 −3
  7. fs/xfs/xfs_trace.h +2 −2
  8. include/linux/trace_events.h +17 −1
  9. include/trace/events/filemap.h +1 −1
  10. include/trace/events/rpcrdma.h +1 −1
  11. include/trace/trace_events.h +21 −43
  12. kernel/trace/trace.h +14 −17
  13. kernel/trace/trace_entries.h +18 −48
  14. kernel/trace/trace_events.c +19 −1
  15. kernel/trace/trace_events_hist.c +7 −1
  16. kernel/trace/trace_export.c +39 −67
  17. kernel/trace/trace_kprobe.c +14 −2
  18. kernel/trace/trace_syscalls.c +20 −30
  19. kernel/trace/trace_uprobe.c +7 −2
  20. net/mac80211/trace.h +14 −14
  21. net/wireless/trace.h +3 −3
drivers/infiniband/hw/hfi1/trace_tid.h+4−4
@@ -138,10 +138,10 @@ TRACE_EVENT(/* put_tid */ · 137 unmodified lines
138138 TP_ARGS(dd, index, type, pa, order),
139139 TP_STRUCT__entry(/* entry */
140140 DD_DEV_ENTRY(dd)
141− __field(unsigned long, pa);
142− __field(u32, index);
143− __field(u32, type);
144− __field(u16, order);
141+ __field(unsigned long, pa)
142+ __field(u32, index)
143+ __field(u32, type)
144+ __field(u16, order)
145145 ),
146146 TP_fast_assign(/* assign */
147147 DD_DEV_ASSIGN(dd);
drivers/infiniband/hw/hfi1/trace_tx.h+1−1
@@ -588,7 +588,7 @@ TRACE_EVENT(hfi1_sdma_user_reqinfo, · 587 unmodified lines
588588 TP_PROTO(struct hfi1_devdata *dd, u16 ctxt, u8 subctxt, u16 *i),
589589 TP_ARGS(dd, ctxt, subctxt, i),
590590 TP_STRUCT__entry(
591− DD_DEV_ENTRY(dd);
591+ DD_DEV_ENTRY(dd)
592592 __field(u16, ctxt)
593593 __field(u8, subctxt)
594594 __field(u8, ver_opcode)
drivers/lightnvm/pblk-trace.h+4−4
@@ -46,7 +46,7 @@ TRACE_EVENT(pblk_chunk_reset, · 45 unmodified lines
4646 TP_STRUCT__entry(
4747 __string(name, name)
4848 __field(u64, ppa)
49− __field(int, state);
49+ __field(int, state)
5050 ),
5151
5252 TP_fast_assign(
@@ -72,7 +72,7 @@ TRACE_EVENT(pblk_chunk_state, · 19 unmodified lines
7272 TP_STRUCT__entry(
7373 __string(name, name)
7474 __field(u64, ppa)
75− __field(int, state);
75+ __field(int, state)
7676 ),
7777
7878 TP_fast_assign(
@@ -98,7 +98,7 @@ TRACE_EVENT(pblk_line_state, · 19 unmodified lines
9898 TP_STRUCT__entry(
9999 __string(name, name)
100100 __field(int, line)
101− __field(int, state);
101+ __field(int, state)
102102 ),
103103
104104 TP_fast_assign(
@@ -121,7 +121,7 @@ TRACE_EVENT(pblk_state, · 16 unmodified lines
121121
122122 TP_STRUCT__entry(
123123 __string(name, name)
124− __field(int, state);
124+ __field(int, state)
125125 ),
126126
127127 TP_fast_assign(
drivers/net/fjes/fjes_trace.h+1−1
@@ -28,7 +28,7 @@ TRACE_EVENT(fjes_hw_issue_request_command, · 27 unmodified lines
2828 __field(u8, cs_busy)
2929 __field(u8, cs_complete)
3030 __field(int, timeout)
31− __field(int, ret);
31+ __field(int, ret)
3232 ),
3333 TP_fast_assign(
3434 __entry->cr_req = cr->bits.req_code;
drivers/net/wireless/ath/ath10k/trace.h+3−3
@@ -239,7 +239,7 @@ TRACE_EVENT(ath10k_wmi_dbglog, · 238 unmodified lines
239239 TP_STRUCT__entry(
240240 __string(device, dev_name(ar->dev))
241241 __string(driver, dev_driver_string(ar->dev))
242− __field(u8, hw_type);
242+ __field(u8, hw_type)
243243 __field(size_t, buf_len)
244244 __dynamic_array(u8, buf, buf_len)
245245 ),
@@ -269,7 +269,7 @@ TRACE_EVENT(ath10k_htt_pktlog, · 23 unmodified lines
269269 TP_STRUCT__entry(
270270 __string(device, dev_name(ar->dev))
271271 __string(driver, dev_driver_string(ar->dev))
272− __field(u8, hw_type);
272+ __field(u8, hw_type)
273273 __field(u16, buf_len)
274274 __dynamic_array(u8, pktlog, buf_len)
275275 ),
@@ -435,7 +435,7 @@ TRACE_EVENT(ath10k_htt_rx_desc, · 159 unmodified lines
435435 TP_STRUCT__entry(
436436 __string(device, dev_name(ar->dev))
437437 __string(driver, dev_driver_string(ar->dev))
438− __field(u8, hw_type);
438+ __field(u8, hw_type)
439439 __field(u16, len)
440440 __dynamic_array(u8, rxdesc, len)
441441 ),
fs/xfs/scrub/trace.h+3−3
@@ -329,7 +329,7 @@ TRACE_EVENT(xchk_btree_op_error, · 328 unmodified lines
329329 __field(int, level)
330330 __field(xfs_agnumber_t, agno)
331331 __field(xfs_agblock_t, bno)
332− __field(int, ptr);
332+ __field(int, ptr)
333333 __field(int, error)
334334 __field(void *, ret_ip)
335335 ),
@@ -414,7 +414,7 @@ TRACE_EVENT(xchk_btree_error, · 78 unmodified lines
414414 __field(int, level)
415415 __field(xfs_agnumber_t, agno)
416416 __field(xfs_agblock_t, bno)
417− __field(int, ptr);
417+ __field(int, ptr)
418418 __field(void *, ret_ip)
419419 ),
420420 TP_fast_assign(
@@ -452,7 +452,7 @@ TRACE_EVENT(xchk_ifork_btree_error, · 31 unmodified lines
452452 __field(int, level)
453453 __field(xfs_agnumber_t, agno)
454454 __field(xfs_agblock_t, bno)
455− __field(int, ptr);
455+ __field(int, ptr)
456456 __field(void *, ret_ip)
457457 ),
458458 TP_fast_assign(
fs/xfs/xfs_trace.h+2−2
@@ -218,8 +218,8 @@ DECLARE_EVENT_CLASS(xfs_bmap_class, · 217 unmodified lines
218218 TP_STRUCT__entry(
219219 __field(dev_t, dev)
220220 __field(xfs_ino_t, ino)
221− __field(void *, leaf);
222− __field(int, pos);
221+ __field(void *, leaf)
222+ __field(int, pos)
223223 __field(xfs_fileoff_t, startoff)
224224 __field(xfs_fsblock_t, startblock)
225225 __field(xfs_filblks_t, blockcount)
include/linux/trace_events.h+17−1
@@ -187,6 +187,22 @@ enum trace_reg { · 186 unmodified lines
187187
188188 struct trace_event_call;
189189
190+#define TRACE_FUNCTION_TYPE ((const char *)~0UL)
191+
192+struct trace_event_fields {
193+ const char *type;
194+ union {
195+ struct {
196+ const char *name;
197+ const int size;
198+ const int align;
199+ const int is_signed;
200+ const int filter_type;
201+ };
202+ int (*define_fields)(struct trace_event_call *);
203+ };
204+};
205+
190206 struct trace_event_class {
191207 const char *system;
192208 void *probe;
@@ -195,7 +211,7 @@ struct trace_event_class { · 2 unmodified lines
195211 #endif
196212 int (*reg)(struct trace_event_call *event,
197213 enum trace_reg type, void *data);
198− int (*define_fields)(struct trace_event_call *);
214+ struct trace_event_fields *fields_array;
199215 struct list_head *(*get_fields)(struct trace_event_call *);
200216 struct list_head fields;
201217 int (*raw_init)(struct trace_event_call *);
include/trace/events/filemap.h+1−1
@@ -85,7 +85,7 @@ TRACE_EVENT(file_check_and_advance_wb_err, · 84 unmodified lines
8585 TP_ARGS(file, old),
8686
8787 TP_STRUCT__entry(
88− __field(struct file *, file);
88+ __field(struct file *, file)
8989 __field(unsigned long, i_ino)
9090 __field(dev_t, s_dev)
9191 __field(errseq_t, old)
include/trace/events/rpcrdma.h+1−1
@@ -1507,7 +1507,7 @@ TRACE_EVENT(svcrdma_dma_map_page, · 1506 unmodified lines
15071507 TP_ARGS(rdma, page),
15081508
15091509 TP_STRUCT__entry(
1510− __field(const void *, page);
1510+ __field(const void *, page)
15111511 __string(device, rdma->sc_cm_id->device->name)
15121512 __string(addr, rdma->sc_xprt.xpt_remotebuf)
15131513 ),
include/trace/trace_events.h+21−43
@@ -394,22 +394,16 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \ · 393 unmodified lines
394394 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
395395
396396 #undef __field_ext
397−#define __field_ext(type, item, filter_type) \
398− ret = trace_define_field(event_call, #type, #item, \
399− offsetof(typeof(field), item), \
400− sizeof(field.item), \
401− is_signed_type(type), filter_type); \
402− if (ret) \
403− return ret;
397+#define __field_ext(_type, _item, _filter_type) { \
398+ .type = #_type, .name = #_item, \
399+ .size = sizeof(_type), .align = __alignof__(_type), \
400+ .is_signed = is_signed_type(_type), .filter_type = _filter_type },
404401
405402 #undef __field_struct_ext
406−#define __field_struct_ext(type, item, filter_type) \
407− ret = trace_define_field(event_call, #type, #item, \
408− offsetof(typeof(field), item), \
409− sizeof(field.item), \
410− 0, filter_type); \
411− if (ret) \
412− return ret;
403+#define __field_struct_ext(_type, _item, _filter_type) { \
404+ .type = #_type, .name = #_item, \
405+ .size = sizeof(_type), .align = __alignof__(_type), \
406+ 0, .filter_type = _filter_type },
413407
414408 #undef __field
415409 #define __field(type, item) __field_ext(type, item, FILTER_OTHER)
@@ -418,25 +412,16 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \ · 2 unmodified lines
418412 #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER)
419413
420414 #undef __array
421−#define __array(type, item, len) \
422− do { \
423− char *type_str = #type"["__stringify(len)"]"; \
424− BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
425− BUILD_BUG_ON(len <= 0); \
426− ret = trace_define_field(event_call, type_str, #item, \
427− offsetof(typeof(field), item), \
428− sizeof(field.item), \
429− is_signed_type(type), FILTER_OTHER); \
430− if (ret) \
431− return ret; \
432− } while (0);
415+#define __array(_type, _item, _len) { \
416+ .type = #_type"["__stringify(_len)"]", .name = #_item, \
417+ .size = sizeof(_type[_len]), .align = __alignof__(_type), \
418+ .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
433419
434420 #undef __dynamic_array
435−#define __dynamic_array(type, item, len) \
436− ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \
437− offsetof(typeof(field), __data_loc_##item), \
438− sizeof(field.__data_loc_##item), \
439− is_signed_type(type), FILTER_OTHER);
421+#define __dynamic_array(_type, _item, _len) { \
422+ .type = "__data_loc " #_type "[]", .name = #_item, \
423+ .size = 4, .align = 4, \
424+ .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER },
440425
441426 #undef __string
442427 #define __string(item, src) __dynamic_array(char, item, -1)
@@ -446,16 +431,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \ · 3 unmodified lines
446431
447432 #undef DECLARE_EVENT_CLASS
448433 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \
449−static int notrace __init \
450−trace_event_define_fields_##call(struct trace_event_call *event_call) \
451−{ \
452− struct trace_event_raw_##call field; \
453− int ret; \
454− \
455− tstruct; \
456− \
457− return ret; \
458−}
434+static struct trace_event_fields trace_event_fields_##call[] = { \
435+ tstruct \
436+ {} };
459437
460438 #undef DEFINE_EVENT
461439 #define DEFINE_EVENT(template, name, proto, args)
@@ -613,7 +591,7 @@ static inline notrace int trace_event_get_offsets_##call( \ · 151 unmodified lines
613591 *
614592 * static struct trace_event_class __used event_class_<template> = {
615593 * .system = "<system>",
616− * .define_fields = trace_event_define_fields_<call>,
594+ * .fields_array = trace_event_fields_<call>,
617595 * .fields = LIST_HEAD_INIT(event_class_##call.fields),
618596 * .raw_init = trace_event_raw_init,
619597 * .probe = trace_event_raw_event_##call,
@@ -761,7 +739,7 @@ _TRACE_PERF_PROTO(call, PARAMS(proto)); \ · 141 unmodified lines
761739 static char print_fmt_##call[] = print; \
762740 static struct trace_event_class __used __refdata event_class_##call = { \
763741 .system = TRACE_SYSTEM_STRING, \
764− .define_fields = trace_event_define_fields_##call, \
742+ .fields_array = trace_event_fields_##call, \
765743 .fields = LIST_HEAD_INIT(event_class_##call.fields),\
766744 .raw_init = trace_event_raw_init, \
767745 .probe = trace_event_raw_event_##call, \
kernel/trace/trace.h+14−17
@@ -49,6 +49,9 @@ enum trace_type { · 48 unmodified lines
4949 #undef __field
5050 #define __field(type, item) type item;
5151
52+#undef __field_fn
53+#define __field_fn(type, item) type item;
54+
5255 #undef __field_struct
5356 #define __field_struct(type, item) __field(type, item)
5457
@@ -68,26 +71,22 @@ enum trace_type { · 13 unmodified lines
6871 #define F_STRUCT(args...) args
6972
7073 #undef FTRACE_ENTRY
71−#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
74+#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
7275 struct struct_name { \
7376 struct trace_entry ent; \
7477 tstruct \
7578 }
7679
7780 #undef FTRACE_ENTRY_DUP
78−#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk, filter)
81+#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk)
7982
8083 #undef FTRACE_ENTRY_REG
81−#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
82− filter, regfn) \
83− FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
84− filter)
84+#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, regfn) \
85+ FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
8586
8687 #undef FTRACE_ENTRY_PACKED
87−#define FTRACE_ENTRY_PACKED(name, struct_name, id, tstruct, print, \
88− filter) \
89− FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
90− filter) __packed
88+#define FTRACE_ENTRY_PACKED(name, struct_name, id, tstruct, print) \
89+ FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) __packed
9190
9291 #include "trace_entries.h"
9392
@@ -1899,17 +1898,15 @@ extern void tracing_log_err(struct trace_array *tr, · 1805 unmodified lines
18991898 #define internal_trace_puts(str) __trace_puts(_THIS_IP_, str, strlen(str))
19001899
19011900 #undef FTRACE_ENTRY
1902−#define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
1901+#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
19031902 extern struct trace_event_call \
19041903 __aligned(4) event_##call;
19051904 #undef FTRACE_ENTRY_DUP
1906−#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
1907− FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
1908− filter)
1905+#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
1906+ FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
19091907 #undef FTRACE_ENTRY_PACKED
1910−#define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print, filter) \
1911− FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
1912− filter)
1908+#define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print) \
1909+ FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
19131910
19141911 #include "trace_entries.h"
19151912
kernel/trace/trace_entries.h+18−48
@@ -61,15 +61,13 @@ FTRACE_ENTRY_REG(function, ftrace_entry, · 60 unmodified lines
6161 TRACE_FN,
6262
6363 F_STRUCT(
64− __field( unsigned long, ip )
65− __field( unsigned long, parent_ip )
64+ __field_fn( unsigned long, ip )
65+ __field_fn( unsigned long, parent_ip )
6666 ),
6767
6868 F_printk(" %ps <-- %ps",
6969 (void *)__entry->ip, (void *)__entry->parent_ip),
7070
71− FILTER_TRACE_FN,
72−
7371 perf_ftrace_event_register
7472 );
7573
@@ -84,9 +82,7 @@ FTRACE_ENTRY_PACKED(funcgraph_entry, ftrace_graph_ent_entry, · 8 unmodified lines
8482 __field_desc( int, graph_ent, depth )
8583 ),
8684
87− F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth),
88−
89− FILTER_OTHER
85+ F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth)
9086 );
9187
9288 /* Function return entry */
@@ -97,18 +93,16 @@ FTRACE_ENTRY_PACKED(funcgraph_exit, ftrace_graph_ret_entry, · 4 unmodified lines
9793 F_STRUCT(
9894 __field_struct( struct ftrace_graph_ret, ret )
9995 __field_desc( unsigned long, ret, func )
96+ __field_desc( unsigned long, ret, overrun )
10097 __field_desc( unsigned long long, ret, calltime)
10198 __field_desc( unsigned long long, ret, rettime )
102− __field_desc( unsigned long, ret, overrun )
10399 __field_desc( int, ret, depth )
104100 ),
105101
106102 F_printk("<-- %ps (%d) (start: %llx end: %llx) over: %d",
107103 (void *)__entry->func, __entry->depth,
108104 __entry->calltime, __entry->rettime,
109− __entry->depth),
110−
111− FILTER_OTHER
105+ __entry->depth)
112106 );
113107
114108 /*
@@ -137,9 +131,7 @@ FTRACE_ENTRY(context_switch, ctx_switch_entry, · 22 unmodified lines
137131 F_printk("%u:%u:%u ==> %u:%u:%u [%03u]",
138132 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
139133 __entry->next_pid, __entry->next_prio, __entry->next_state,
140− __entry->next_cpu),
141−
142− FILTER_OTHER
134+ __entry->next_cpu)
143135 );
144136
145137 /*
@@ -157,9 +149,7 @@ FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry, · 11 unmodified lines
157149 F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]",
158150 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
159151 __entry->next_pid, __entry->next_prio, __entry->next_state,
160− __entry->next_cpu),
161−
162− FILTER_OTHER
152+ __entry->next_cpu)
163153 );
164154
165155 /*
@@ -183,9 +173,7 @@ FTRACE_ENTRY(kernel_stack, stack_entry, · 17 unmodified lines
183173 (void *)__entry->caller[0], (void *)__entry->caller[1],
184174 (void *)__entry->caller[2], (void *)__entry->caller[3],
185175 (void *)__entry->caller[4], (void *)__entry->caller[5],
186− (void *)__entry->caller[6], (void *)__entry->caller[7]),
187−
188− FILTER_OTHER
176+ (void *)__entry->caller[6], (void *)__entry->caller[7])
189177 );
190178
191179 FTRACE_ENTRY(user_stack, userstack_entry,
@@ -203,9 +191,7 @@ FTRACE_ENTRY(user_stack, userstack_entry, · 11 unmodified lines
203191 (void *)__entry->caller[0], (void *)__entry->caller[1],
204192 (void *)__entry->caller[2], (void *)__entry->caller[3],
205193 (void *)__entry->caller[4], (void *)__entry->caller[5],
206− (void *)__entry->caller[6], (void *)__entry->caller[7]),
207−
208− FILTER_OTHER
194+ (void *)__entry->caller[6], (void *)__entry->caller[7])
209195 );
210196
211197 /*
@@ -222,9 +208,7 @@ FTRACE_ENTRY(bprint, bprint_entry, · 10 unmodified lines
222208 ),
223209
224210 F_printk("%ps: %s",
225− (void *)__entry->ip, __entry->fmt),
226−
227− FILTER_OTHER
211+ (void *)__entry->ip, __entry->fmt)
228212 );
229213
230214 FTRACE_ENTRY_REG(print, print_entry,
@@ -239,8 +223,6 @@ FTRACE_ENTRY_REG(print, print_entry, · 8 unmodified lines
239223 F_printk("%ps: %s",
240224 (void *)__entry->ip, __entry->buf),
241225
242− FILTER_OTHER,
243−
244226 ftrace_event_register
245227 );
246228
@@ -254,9 +236,7 @@ FTRACE_ENTRY(raw_data, raw_data_entry, · 7 unmodified lines
254236 ),
255237
256238 F_printk("id:%04x %08x",
257− __entry->id, (int)__entry->buf[0]),
258−
259− FILTER_OTHER
239+ __entry->id, (int)__entry->buf[0])
260240 );
261241
262242 FTRACE_ENTRY(bputs, bputs_entry,
@@ -269,9 +249,7 @@ FTRACE_ENTRY(bputs, bputs_entry, · 6 unmodified lines
269249 ),
270250
271251 F_printk("%ps: %s",
272− (void *)__entry->ip, __entry->str),
273−
274− FILTER_OTHER
252+ (void *)__entry->ip, __entry->str)
275253 );
276254
277255 FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
@@ -283,16 +261,14 @@ FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw, · 5 unmodified lines
283261 __field_desc( resource_size_t, rw, phys )
284262 __field_desc( unsigned long, rw, value )
285263 __field_desc( unsigned long, rw, pc )
286− __field_desc( int, rw, map_id )
264+ __field_desc( int, rw, map_id )
287265 __field_desc( unsigned char, rw, opcode )
288266 __field_desc( unsigned char, rw, width )
289267 ),
290268
291269 F_printk("%lx %lx %lx %d %x %x",
292270 (unsigned long)__entry->phys, __entry->value, __entry->pc,
293− __entry->map_id, __entry->opcode, __entry->width),
294−
295− FILTER_OTHER
271+ __entry->map_id, __entry->opcode, __entry->width)
296272 );
297273
298274 FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
@@ -304,15 +280,13 @@ FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map, · 5 unmodified lines
304280 __field_desc( resource_size_t, map, phys )
305281 __field_desc( unsigned long, map, virt )
306282 __field_desc( unsigned long, map, len )
307− __field_desc( int, map, map_id )
283+ __field_desc( int, map, map_id )
308284 __field_desc( unsigned char, map, opcode )
309285 ),
310286
311287 F_printk("%lx %lx %lx %d %x",
312288 (unsigned long)__entry->phys, __entry->virt, __entry->len,
313− __entry->map_id, __entry->opcode),
314−
315− FILTER_OTHER
289+ __entry->map_id, __entry->opcode)
316290 );
317291
318292
@@ -334,9 +308,7 @@ FTRACE_ENTRY(branch, trace_branch, · 15 unmodified lines
334308 F_printk("%u:%s:%s (%u)%s",
335309 __entry->line,
336310 __entry->func, __entry->file, __entry->correct,
337− __entry->constant ? " CONSTANT" : ""),
338−
339− FILTER_OTHER
311+ __entry->constant ? " CONSTANT" : "")
340312 );
341313
342314
@@ -362,7 +334,5 @@ FTRACE_ENTRY(hwlat, hwlat_entry, · 19 unmodified lines
362334 __entry->duration,
363335 __entry->outer_duration,
364336 __entry->nmi_total_ts,
365− __entry->nmi_count),
366−
367− FILTER_OTHER
337+ __entry->nmi_count)
368338 );
kernel/trace/trace_events.c+19−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <linux/delay.h>
2525
2626 #include <trace/events/sched.h>
27+#include <trace/syscall.h>
2728
2829 #include <asm/setup.h>
2930
@@ -1990,7 +1991,24 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) · 1960 unmodified lines
19901991 */
19911992 head = trace_get_fields(call);
19921993 if (list_empty(head)) {
1993− ret = call->class->define_fields(call);
1994+ struct trace_event_fields *field = call->class->fields_array;
1995+ unsigned int offset = sizeof(struct trace_entry);
1996+
1997+ for (; field->type; field++) {
1998+ if (field->type == TRACE_FUNCTION_TYPE) {
1999+ ret = field->define_fields(call);
2000+ break;
2001+ }
2002+
2003+ offset = ALIGN(offset, field->align);
2004+ ret = trace_define_field(call, field->type, field->name,
2005+ offset, field->size,
2006+ field->is_signed, field->filter_type);
2007+ if (ret)
2008+ break;
2009+
2010+ offset += field->size;
2011+ }
19942012 if (ret < 0) {
19952013 pr_warn("Could not initialize trace point events/%s\n",
19962014 name);
kernel/trace/trace_events_hist.c+7−1
@@ -1135,6 +1135,12 @@ static struct synth_event *find_synth_event(const char *name) · 1134 unmodified lines
11351135 return NULL;
11361136 }
11371137
1138+static struct trace_event_fields synth_event_fields_array[] = {
1139+ { .type = TRACE_FUNCTION_TYPE,
1140+ .define_fields = synth_event_define_fields },
1141+ {}
1142+};
1143+
11381144 static int register_synth_event(struct synth_event *event)
11391145 {
11401146 struct trace_event_call *call = &event->call;
@@ -1156,7 +1162,7 @@ static int register_synth_event(struct synth_event *event) · 15 unmodified lines
11561162
11571163 INIT_LIST_HEAD(&call->class->fields);
11581164 call->event.funcs = &synth_event_funcs;
1159− call->class->define_fields = synth_event_define_fields;
1165+ call->class->fields_array = synth_event_fields_array;
11601166
11611167 ret = register_trace_event(&call->event);
11621168 if (!ret) {
kernel/trace/trace_export.c+39−67
@@ -29,10 +29,8 @@ static int ftrace_event_register(struct trace_event_call *call, · 28 unmodified lines
2929 * function and thus become accesible via perf.
3030 */
3131 #undef FTRACE_ENTRY_REG
32−#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
33− filter, regfn) \
34− FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
35− filter)
32+#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, regfn) \
33+ FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
3634
3735 /* not needed for this file */
3836 #undef __field_struct
@@ -41,6 +39,9 @@ static int ftrace_event_register(struct trace_event_call *call, · 2 unmodified lines
4139 #undef __field
4240 #define __field(type, item) type item;
4341
42+#undef __field_fn
43+#define __field_fn(type, item) type item;
44+
4445 #undef __field_desc
4546 #define __field_desc(type, container, item) type item;
4647
@@ -60,7 +61,7 @@ static int ftrace_event_register(struct trace_event_call *call, · 13 unmodified lines
6061 #define F_printk(fmt, args...) fmt, args
6162
6263 #undef FTRACE_ENTRY
63−#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
64+#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
6465 struct ____ftrace_##name { \
6566 tstruct \
6667 }; \
@@ -73,76 +74,46 @@ static void __always_unused ____ftrace_check_##name(void) \ · 6 unmodified lines
7374 }
7475
7576 #undef FTRACE_ENTRY_DUP
76−#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print, filter) \
77− FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
78− filter)
77+#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \
78+ FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
7979
8080 #include "trace_entries.h"
8181
82+#undef __field_ext
83+#define __field_ext(_type, _item, _filter_type) { \
84+ .type = #_type, .name = #_item, \
85+ .size = sizeof(_type), .align = __alignof__(_type), \
86+ is_signed_type(_type), .filter_type = _filter_type },
87+
8288 #undef __field
83−#define __field(type, item) \
84− ret = trace_define_field(event_call, #type, #item, \
85− offsetof(typeof(field), item), \
86− sizeof(field.item), \
87− is_signed_type(type), filter_type); \
88− if (ret) \
89− return ret;
89+#define __field(_type, _item) __field_ext(_type, _item, FILTER_OTHER)
90+
91+#undef __field_fn
92+#define __field_fn(_type, _item) __field_ext(_type, _item, FILTER_TRACE_FN)
9093
9194 #undef __field_desc
92−#define __field_desc(type, container, item) \
93− ret = trace_define_field(event_call, #type, #item, \
94− offsetof(typeof(field), \
95− container.item), \
96− sizeof(field.container.item), \
97− is_signed_type(type), filter_type); \
98− if (ret) \
99− return ret;
95+#define __field_desc(_type, _container, _item) __field_ext(_type, _item, FILTER_OTHER)
10096
10197 #undef __array
102−#define __array(type, item, len) \
103− do { \
104− char *type_str = #type"["__stringify(len)"]"; \
105− BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
106− ret = trace_define_field(event_call, type_str, #item, \
107− offsetof(typeof(field), item), \
108− sizeof(field.item), \
109− is_signed_type(type), filter_type); \
110− if (ret) \
111− return ret; \
112− } while (0);
98+#define __array(_type, _item, _len) { \
99+ .type = #_type"["__stringify(_len)"]", .name = #_item, \
100+ .size = sizeof(_type[_len]), .align = __alignof__(_type), \
101+ is_signed_type(_type), .filter_type = FILTER_OTHER },
113102
114103 #undef __array_desc
115−#define __array_desc(type, container, item, len) \
116− BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
117− ret = trace_define_field(event_call, #type "[" #len "]", #item, \
118− offsetof(typeof(field), \
119− container.item), \
120− sizeof(field.container.item), \
121− is_signed_type(type), filter_type); \
122− if (ret) \
123− return ret;
104+#define __array_desc(_type, _container, _item, _len) __array(_type, _item, _len)
124105
125106 #undef __dynamic_array
126−#define __dynamic_array(type, item) \
127− ret = trace_define_field(event_call, #type "[]", #item, \
128− offsetof(typeof(field), item), \
129− 0, is_signed_type(type), filter_type);\
130− if (ret) \
131− return ret;
107+#define __dynamic_array(_type, _item) { \
108+ .type = #_type "[]", .name = #_item, \
109+ .size = 0, .align = __alignof__(_type), \
110+ is_signed_type(_type), .filter_type = FILTER_OTHER },
132111
133112 #undef FTRACE_ENTRY
134−#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
135−static int __init \
136−ftrace_define_fields_##name(struct trace_event_call *event_call) \
137−{ \
138− struct struct_name field; \
139− int ret; \
140− int filter_type = filter; \
141− \
142− tstruct; \
143− \
144− return ret; \
145−}
113+#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
114+static struct trace_event_fields ftrace_event_fields_##name[] = { \
115+ tstruct \
116+ {} };
146117
147118 #include "trace_entries.h"
148119
@@ -152,6 +123,9 @@ ftrace_define_fields_##name(struct trace_event_call *event_call) \ · 3 unmodified lines
152123 #undef __field
153124 #define __field(type, item)
154125
126+#undef __field_fn
127+#define __field_fn(type, item)
128+
155129 #undef __field_desc
156130 #define __field_desc(type, container, item)
157131
@@ -168,12 +142,10 @@ ftrace_define_fields_##name(struct trace_event_call *event_call) \ · 10 unmodified lines
168142 #define F_printk(fmt, args...) __stringify(fmt) ", " __stringify(args)
169143
170144 #undef FTRACE_ENTRY_REG
171−#define FTRACE_ENTRY_REG(call, struct_name, etype, tstruct, print, filter,\
172− regfn) \
173− \
145+#define FTRACE_ENTRY_REG(call, struct_name, etype, tstruct, print, regfn) \
174146 struct trace_event_class __refdata event_class_ftrace_##call = { \
175147 .system = __stringify(TRACE_SYSTEM), \
176− .define_fields = ftrace_define_fields_##call, \
148+ .fields_array = ftrace_event_fields_##call, \
177149 .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\
178150 .reg = regfn, \
179151 }; \
@@ -191,9 +163,9 @@ struct trace_event_call __used \ · 11 unmodified lines
191163 __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;
192164
193165 #undef FTRACE_ENTRY
194−#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print, filter) \
166+#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print) \
195167 FTRACE_ENTRY_REG(call, struct_name, etype, \
196− PARAMS(tstruct), PARAMS(print), filter, NULL)
168+ PARAMS(tstruct), PARAMS(print), NULL)
197169
198170 bool ftrace_event_is_function(struct trace_event_call *call)
199171 {
kernel/trace/trace_kprobe.c+14−2
@@ -1534,16 +1534,28 @@ static struct trace_event_functions kprobe_funcs = { · 1533 unmodified lines
15341534 .trace = print_kprobe_event
15351535 };
15361536
1537+static struct trace_event_fields kretprobe_fields_array[] = {
1538+ { .type = TRACE_FUNCTION_TYPE,
1539+ .define_fields = kretprobe_event_define_fields },
1540+ {}
1541+};
1542+
1543+static struct trace_event_fields kprobe_fields_array[] = {
1544+ { .type = TRACE_FUNCTION_TYPE,
1545+ .define_fields = kprobe_event_define_fields },
1546+ {}
1547+};
1548+
15371549 static inline void init_trace_event_call(struct trace_kprobe *tk)
15381550 {
15391551 struct trace_event_call *call = trace_probe_event_call(&tk->tp);
15401552
15411553 if (trace_kprobe_is_return(tk)) {
15421554 call->event.funcs = &kretprobe_funcs;
1543− call->class->define_fields = kretprobe_event_define_fields;
1555+ call->class->fields_array = kretprobe_fields_array;
15441556 } else {
15451557 call->event.funcs = &kprobe_funcs;
1546− call->class->define_fields = kprobe_event_define_fields;
1558+ call->class->fields_array = kprobe_fields_array;
15471559 }
15481560
15491561 call->flags = TRACE_EVENT_FL_KPROBE;
kernel/trace/trace_syscalls.c+20−30
@@ -198,11 +198,10 @@ print_syscall_exit(struct trace_iterator *iter, int flags, · 197 unmodified lines
198198
199199 extern char *__bad_type_size(void);
200200
201−#define SYSCALL_FIELD(type, field, name) \
202− sizeof(type) != sizeof(trace.field) ? \
203− __bad_type_size() : \
204− #type, #name, offsetof(typeof(trace), field), \
205− sizeof(trace.field), is_signed_type(type)
201+#define SYSCALL_FIELD(_type, _name) { \
202+ .type = #_type, .name = #_name, \
203+ .size = sizeof(_type), .align = __alignof__(_type), \
204+ .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }
206205
207206 static int __init
208207 __set_enter_print_fmt(struct syscall_metadata *entry, char *buf, int len)
@@ -269,42 +268,22 @@ static int __init syscall_enter_define_fields(struct trace_event_call *call) · 60 unmodified lines
269268 {
270269 struct syscall_trace_enter trace;
271270 struct syscall_metadata *meta = call->data;
272− int ret;
273− int i;
274271 int offset = offsetof(typeof(trace), args);
275−
276− ret = trace_define_field(call, SYSCALL_FIELD(int, nr, __syscall_nr),
277− FILTER_OTHER);
278− if (ret)
279− return ret;
272+ int ret, i;
280273
281274 for (i = 0; i < meta->nb_args; i++) {
282275 ret = trace_define_field(call, meta->types[i],
283276 meta->args[i], offset,
284277 sizeof(unsigned long), 0,
285278 FILTER_OTHER);
279+ if (ret)
280+ break;
286281 offset += sizeof(unsigned long);
287282 }
288283
289284 return ret;
290285 }
291286
292−static int __init syscall_exit_define_fields(struct trace_event_call *call)
293−{
294− struct syscall_trace_exit trace;
295− int ret;
296−
297− ret = trace_define_field(call, SYSCALL_FIELD(int, nr, __syscall_nr),
298− FILTER_OTHER);
299− if (ret)
300− return ret;
301−
302− ret = trace_define_field(call, SYSCALL_FIELD(long, ret, ret),
303− FILTER_OTHER);
304−
305− return ret;
306−}
307−
308287 static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
309288 {
310289 struct trace_array *tr = data;
@@ -502,6 +481,13 @@ static int __init init_syscall_trace(struct trace_event_call *call) · 191 unmodified lines
502481 return id;
503482 }
504483
484+static struct trace_event_fields __refdata syscall_enter_fields_array[] = {
485+ SYSCALL_FIELD(int, __syscall_nr),
486+ { .type = TRACE_FUNCTION_TYPE,
487+ .define_fields = syscall_enter_define_fields },
488+ {}
489+};
490+
505491 struct trace_event_functions enter_syscall_print_funcs = {
506492 .trace = print_syscall_enter,
507493 };
@@ -513,7 +499,7 @@ struct trace_event_functions exit_syscall_print_funcs = { · 5 unmodified lines
513499 struct trace_event_class __refdata event_class_syscall_enter = {
514500 .system = "syscalls",
515501 .reg = syscall_enter_register,
516− .define_fields = syscall_enter_define_fields,
502+ .fields_array = syscall_enter_fields_array,
517503 .get_fields = syscall_get_enter_fields,
518504 .raw_init = init_syscall_trace,
519505 };
@@ -521,7 +507,11 @@ struct trace_event_class __refdata event_class_syscall_enter = { · 1 unmodified line
521507 struct trace_event_class __refdata event_class_syscall_exit = {
522508 .system = "syscalls",
523509 .reg = syscall_exit_register,
524− .define_fields = syscall_exit_define_fields,
510+ .fields_array = (struct trace_event_fields[]){
511+ SYSCALL_FIELD(int, __syscall_nr),
512+ SYSCALL_FIELD(long, ret),
513+ {}
514+ },
525515 .fields = LIST_HEAD_INIT(event_class_syscall_exit.fields),
526516 .raw_init = init_syscall_trace,
527517 };
kernel/trace/trace_uprobe.c+7−2
@@ -1507,12 +1507,17 @@ static struct trace_event_functions uprobe_funcs = { · 1506 unmodified lines
15071507 .trace = print_uprobe_event
15081508 };
15091509
1510+static struct trace_event_fields uprobe_fields_array[] = {
1511+ { .type = TRACE_FUNCTION_TYPE,
1512+ .define_fields = uprobe_event_define_fields },
1513+ {}
1514+};
1515+
15101516 static inline void init_trace_event_call(struct trace_uprobe *tu)
15111517 {
15121518 struct trace_event_call *call = trace_probe_event_call(&tu->tp);
1513−
15141519 call->event.funcs = &uprobe_funcs;
1515− call->class->define_fields = uprobe_event_define_fields;
1520+ call->class->fields_array = uprobe_fields_array;
15161521
15171522 call->flags = TRACE_EVENT_FL_UPROBE | TRACE_EVENT_FL_CAP_ANY;
15181523 call->class->reg = trace_uprobe_register;
net/mac80211/trace.h+14−14
@@ -408,20 +408,20 @@ TRACE_EVENT(drv_bss_info_changed, · 407 unmodified lines
408408 __field(u32, basic_rates)
409409 __array(int, mcast_rate, NUM_NL80211_BANDS)
410410 __field(u16, ht_operation_mode)
411− __field(s32, cqm_rssi_thold);
412− __field(s32, cqm_rssi_hyst);
413− __field(u32, channel_width);
414− __field(u32, channel_cfreq1);
411+ __field(s32, cqm_rssi_thold)
412+ __field(s32, cqm_rssi_hyst)
413+ __field(u32, channel_width)
414+ __field(u32, channel_cfreq1)
415415 __dynamic_array(u32, arp_addr_list,
416416 info->arp_addr_cnt > IEEE80211_BSS_ARP_ADDR_LIST_LEN ?
417417 IEEE80211_BSS_ARP_ADDR_LIST_LEN :
418− info->arp_addr_cnt);
419− __field(int, arp_addr_cnt);
420− __field(bool, qos);
421− __field(bool, idle);
422− __field(bool, ps);
423− __dynamic_array(u8, ssid, info->ssid_len);
424− __field(bool, hidden_ssid);
418+ info->arp_addr_cnt)
419+ __field(int, arp_addr_cnt)
420+ __field(bool, qos)
421+ __field(bool, idle)
422+ __field(bool, ps)
423+ __dynamic_array(u8, ssid, info->ssid_len)
424+ __field(bool, hidden_ssid)
425425 __field(int, txpower)
426426 __field(u8, p2p_oppps_ctwindow)
427427 ),
@@ -1672,8 +1672,8 @@ TRACE_EVENT(drv_start_ap, · 1244 unmodified lines
16721672 VIF_ENTRY
16731673 __field(u8, dtimper)
16741674 __field(u16, bcnint)
1675− __dynamic_array(u8, ssid, info->ssid_len);
1676− __field(bool, hidden_ssid);
1675+ __dynamic_array(u8, ssid, info->ssid_len)
1676+ __field(bool, hidden_ssid)
16771677 ),
16781678
16791679 TP_fast_assign(
@@ -1739,7 +1739,7 @@ TRACE_EVENT(drv_join_ibss, · 59 unmodified lines
17391739 VIF_ENTRY
17401740 __field(u8, dtimper)
17411741 __field(u16, bcnint)
1742− __dynamic_array(u8, ssid, info->ssid_len);
1742+ __dynamic_array(u8, ssid, info->ssid_len)
17431743 ),
17441744
17451745 TP_fast_assign(
net/wireless/trace.h+3−3
@@ -2009,7 +2009,7 @@ TRACE_EVENT(rdev_start_nan, · 2008 unmodified lines
20092009 WIPHY_ENTRY
20102010 WDEV_ENTRY
20112011 __field(u8, master_pref)
2012− __field(u8, bands);
2012+ __field(u8, bands)
20132013 ),
20142014 TP_fast_assign(
20152015 WIPHY_ASSIGN;
@@ -2031,8 +2031,8 @@ TRACE_EVENT(rdev_nan_change_conf, · 15 unmodified lines
20312031 WIPHY_ENTRY
20322032 WDEV_ENTRY
20332033 __field(u8, master_pref)
2034− __field(u8, bands);
2035− __field(u32, changes);
2034+ __field(u8, bands)
2035+ __field(u32, changes)
20362036 ),
20372037 TP_fast_assign(
20382038 WIPHY_ASSIGN;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t