diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-01-27 09:15:30 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-02-02 21:37:13 -0500 |
commit | e4a9ea5ee7c8812a7bf0c3fb725ceeaa3d4c2fcc (patch) | |
tree | 1b25668508fa302a6ada053c895cd55727f798f1 /kernel | |
parent | 9ffdc6c37df131f89d52001e0ef03091b158826f (diff) |
tracing: Replace trace_event struct array with pointer array
Currently the trace_event structures are placed in the _ftrace_events
section, and at link time, the linker makes one large array of all
the trace_event structures. On boot up, this array is read (much like
the initcall sections) and the events are processed.
The problem is that there is no guarantee that gcc will place complex
structures nicely together in an array format. Two structures in the
same file may be placed awkwardly, because gcc has no clue that they
are suppose to be in an array.
A hack was used previous to force the alignment to 4, to pack the
structures together. But this caused alignment issues with other
architectures (sparc).
Instead of packing the structures into an array, the structures' addresses
are now put into the _ftrace_event section. As pointers are always the
natural alignment, gcc should always pack them tightly together
(otherwise initcall, extable, etc would also fail).
By having the pointers to the structures in the section, we can still
iterate the trace_events without causing unnecessary alignment problems
with other architectures, or depending on the current behaviour of
gcc that will likely change in the future just to tick us kernel developers
off a little more.
The _ftrace_event section is also moved into the .init.data section
as it is now only needed at boot up.
Suggested-by: David Miller <davem@davemloft.net>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_events.c | 12 | ||||
-rw-r--r-- | kernel/trace/trace_export.c | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 35fde09b81de..5f499e0438a4 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -1284,7 +1284,7 @@ trace_create_file_ops(struct module *mod) | |||
1284 | static void trace_module_add_events(struct module *mod) | 1284 | static void trace_module_add_events(struct module *mod) |
1285 | { | 1285 | { |
1286 | struct ftrace_module_file_ops *file_ops = NULL; | 1286 | struct ftrace_module_file_ops *file_ops = NULL; |
1287 | struct ftrace_event_call *call, *start, *end; | 1287 | struct ftrace_event_call **call, **start, **end; |
1288 | 1288 | ||
1289 | start = mod->trace_events; | 1289 | start = mod->trace_events; |
1290 | end = mod->trace_events + mod->num_trace_events; | 1290 | end = mod->trace_events + mod->num_trace_events; |
@@ -1297,7 +1297,7 @@ static void trace_module_add_events(struct module *mod) | |||
1297 | return; | 1297 | return; |
1298 | 1298 | ||
1299 | for_each_event(call, start, end) { | 1299 | for_each_event(call, start, end) { |
1300 | __trace_add_event_call(call, mod, | 1300 | __trace_add_event_call(*call, mod, |
1301 | &file_ops->id, &file_ops->enable, | 1301 | &file_ops->id, &file_ops->enable, |
1302 | &file_ops->filter, &file_ops->format); | 1302 | &file_ops->filter, &file_ops->format); |
1303 | } | 1303 | } |
@@ -1367,8 +1367,8 @@ static struct notifier_block trace_module_nb = { | |||
1367 | .priority = 0, | 1367 | .priority = 0, |
1368 | }; | 1368 | }; |
1369 | 1369 | ||
1370 | extern struct ftrace_event_call __start_ftrace_events[]; | 1370 | extern struct ftrace_event_call *__start_ftrace_events[]; |
1371 | extern struct ftrace_event_call __stop_ftrace_events[]; | 1371 | extern struct ftrace_event_call *__stop_ftrace_events[]; |
1372 | 1372 | ||
1373 | static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata; | 1373 | static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata; |
1374 | 1374 | ||
@@ -1384,7 +1384,7 @@ __setup("trace_event=", setup_trace_event); | |||
1384 | 1384 | ||
1385 | static __init int event_trace_init(void) | 1385 | static __init int event_trace_init(void) |
1386 | { | 1386 | { |
1387 | struct ftrace_event_call *call; | 1387 | struct ftrace_event_call **call; |
1388 | struct dentry *d_tracer; | 1388 | struct dentry *d_tracer; |
1389 | struct dentry *entry; | 1389 | struct dentry *entry; |
1390 | struct dentry *d_events; | 1390 | struct dentry *d_events; |
@@ -1430,7 +1430,7 @@ static __init int event_trace_init(void) | |||
1430 | pr_warning("tracing: Failed to allocate common fields"); | 1430 | pr_warning("tracing: Failed to allocate common fields"); |
1431 | 1431 | ||
1432 | for_each_event(call, __start_ftrace_events, __stop_ftrace_events) { | 1432 | for_each_event(call, __start_ftrace_events, __stop_ftrace_events) { |
1433 | __trace_add_event_call(call, NULL, &ftrace_event_id_fops, | 1433 | __trace_add_event_call(*call, NULL, &ftrace_event_id_fops, |
1434 | &ftrace_enable_fops, | 1434 | &ftrace_enable_fops, |
1435 | &ftrace_event_filter_fops, | 1435 | &ftrace_event_filter_fops, |
1436 | &ftrace_event_format_fops); | 1436 | &ftrace_event_format_fops); |
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index 4b74d71705c0..bbeec31e0ae3 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -161,13 +161,13 @@ struct ftrace_event_class event_class_ftrace_##call = { \ | |||
161 | .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ | 161 | .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ |
162 | }; \ | 162 | }; \ |
163 | \ | 163 | \ |
164 | struct ftrace_event_call __used \ | 164 | struct ftrace_event_call __used event_##call = { \ |
165 | __attribute__((__aligned__(4))) \ | ||
166 | __attribute__((section("_ftrace_events"))) event_##call = { \ | ||
167 | .name = #call, \ | 165 | .name = #call, \ |
168 | .event.type = etype, \ | 166 | .event.type = etype, \ |
169 | .class = &event_class_ftrace_##call, \ | 167 | .class = &event_class_ftrace_##call, \ |
170 | .print_fmt = print, \ | 168 | .print_fmt = print, \ |
171 | }; \ | 169 | }; \ |
170 | struct ftrace_event_call __used \ | ||
171 | __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; | ||
172 | 172 | ||
173 | #include "trace_entries.h" | 173 | #include "trace_entries.h" |