]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
tracing: Move raw_init from events to class
authorSteven Rostedt <srostedt@redhat.com>
Thu, 22 Apr 2010 15:46:44 +0000 (11:46 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 14 May 2010 18:20:30 +0000 (14:20 -0400)
The raw_init function pointer in the event is used to initialize
various kinds of events. The type of initialization needed is usually
classed to the kind of event it is.

Two events with the same class will always have the same initialization
function, so it makes sense to move this to the class structure.

Perhaps even making a special system structure would work since
the initialization is the same for all events within a system.
But since there's no system structure (yet), this will just move it
to the class.

   text    data     bss     dec     hex filename
4913961 1088356  861512 6863829  68bbd5 vmlinux.orig
4900375 1053380  861512 6815267  67fe23 vmlinux.fields
4900382 1048964  861512 6810858  67ecea vmlinux.init

The text grew very slightly, but this is a constant growth that happened
with the changing of the C files that call the init code.
The bigger savings is the data which will be saved the more events share
a class.

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/ftrace_event.h
include/linux/syscalls.h
include/trace/ftrace.h
kernel/trace/trace_events.c
kernel/trace/trace_export.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_syscalls.c

index 479c3c1876e6c487de7ff31da62b5d16110aebb7..393a8394df0e2ce3b7fcd52eaf8f140ea3bcb727 100644 (file)
@@ -133,6 +133,7 @@ struct ftrace_event_class {
        int                     (*define_fields)(struct ftrace_event_call *);
        struct list_head        *(*get_fields)(struct ftrace_event_call *);
        struct list_head        fields;
+       int                     (*raw_init)(struct ftrace_event_call *);
 };
 
 struct ftrace_event_call {
@@ -144,7 +145,6 @@ struct ftrace_event_call {
        int                     enabled;
        int                     id;
        const char              *print_fmt;
-       int                     (*raw_init)(struct ftrace_event_call *);
        int                     filter_active;
        struct event_filter     *filter;
        void                    *mod;
index fd0f1f248cd8cfe0ac208bbeaa44f907b3883aaa..211c704a71edacbcad7c01e7579379a21d587fe0 100644 (file)
@@ -135,7 +135,6 @@ extern struct ftrace_event_class event_class_syscall_exit;
                .name                   = "sys_enter"#sname,            \
                .class                  = &event_class_syscall_enter,   \
                .event                  = &enter_syscall_print_##sname, \
-               .raw_init               = init_syscall_trace,           \
                .data                   = (void *)&__syscall_meta_##sname,\
        }
 
@@ -153,7 +152,6 @@ extern struct ftrace_event_class event_class_syscall_exit;
                .name                   = "sys_exit"#sname,             \
                .class                  = &event_class_syscall_exit,    \
                .event                  = &exit_syscall_print_##sname,  \
-               .raw_init               = init_syscall_trace,           \
                .data                   = (void *)&__syscall_meta_##sname,\
        }
 
index c7e3bcd5d52f0c96766eedf91bd73826a31af36d..e7eb33420b0671e97706af7f5722fff02b12d281 100644 (file)
@@ -431,8 +431,9 @@ static inline notrace int ftrace_get_offsets_##call(                        \
  * static struct ftrace_event_class __used event_class_<template> = {
  *     .system                 = "<system>",
  *     .define_fields          = ftrace_define_fields_<call>,
- *     .fields                 = LIST_HEAD_INIT(event_class_##call.fields), \
- *     .probe                  = ftrace_raw_event_##call,              \
+ *     .fields                 = LIST_HEAD_INIT(event_class_##call.fields),
+ *     .raw_init               = trace_event_raw_init,
+ *     .probe                  = ftrace_raw_event_##call,
  * };
  *
  * static struct ftrace_event_call __used
@@ -440,7 +441,6 @@ static inline notrace int ftrace_get_offsets_##call(                        \
  * __attribute__((section("_ftrace_events"))) event_<call> = {
  *     .name                   = "<call>",
  *     .class                  = event_class_<template>,
- *     .raw_init               = trace_event_raw_init,
  *     .event                  = &ftrace_event_type_<call>,
  *     .print_fmt              = print_fmt_<call>,
  * };
@@ -566,6 +566,7 @@ static struct ftrace_event_class __used event_class_##call = {              \
        .system                 = __stringify(TRACE_SYSTEM),            \
        .define_fields          = ftrace_define_fields_##call,          \
        .fields                 = LIST_HEAD_INIT(event_class_##call.fields),\
+       .raw_init               = trace_event_raw_init,                 \
        .probe                  = ftrace_raw_event_##call,              \
        _TRACE_PERF_INIT(call)                                          \
 };
@@ -579,7 +580,6 @@ __attribute__((section("_ftrace_events"))) event_##call = {         \
        .name                   = #call,                                \
        .class                  = &event_class_##template,              \
        .event                  = &ftrace_event_type_##call,            \
-       .raw_init               = trace_event_raw_init,                 \
        .print_fmt              = print_fmt_##template,                 \
 };
 
@@ -594,7 +594,6 @@ __attribute__((section("_ftrace_events"))) event_##call = {         \
        .name                   = #call,                                \
        .class                  = &event_class_##template,              \
        .event                  = &ftrace_event_type_##call,            \
-       .raw_init               = trace_event_raw_init,                 \
        .print_fmt              = print_fmt_##call,                     \
 }
 
index acc0f55742c321c15c332b6ceed79403c411c8dc..8e94255a45e724b3ae9c3a0cad9ca4c4b721484f 100644 (file)
@@ -1008,8 +1008,8 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
        if (!call->name)
                return -EINVAL;
 
-       if (call->raw_init) {
-               ret = call->raw_init(call);
+       if (call->class->raw_init) {
+               ret = call->class->raw_init(call);
                if (ret < 0) {
                        if (ret != -ENOSYS)
                                pr_warning("Could not initialize trace "
@@ -1170,8 +1170,8 @@ static void trace_module_add_events(struct module *mod)
                /* The linker may leave blanks */
                if (!call->name)
                        continue;
-               if (call->raw_init) {
-                       ret = call->raw_init(call);
+               if (call->class->raw_init) {
+                       ret = call->class->raw_init(call);
                        if (ret < 0) {
                                if (ret != -ENOSYS)
                                        pr_warning("Could not initialize trace "
@@ -1324,8 +1324,8 @@ static __init int event_trace_init(void)
                /* The linker may leave blanks */
                if (!call->name)
                        continue;
-               if (call->raw_init) {
-                       ret = call->raw_init(call);
+               if (call->class->raw_init) {
+                       ret = call->class->raw_init(call);
                        if (ret < 0) {
                                if (ret != -ENOSYS)
                                        pr_warning("Could not initialize trace "
index e700a0c1803f1110dd27236f0c2775d96bebb4bb..e878d06c0ac00df2e1577c45b666d55bb6b224bc 100644 (file)
@@ -158,6 +158,7 @@ static int ftrace_raw_init_event(struct ftrace_event_call *call)
 struct ftrace_event_class event_class_ftrace_##call = {                        \
        .system                 = __stringify(TRACE_SYSTEM),            \
        .define_fields          = ftrace_define_fields_##call,          \
+       .raw_init               = ftrace_raw_init_event,                \
 };                                                                     \
                                                                        \
 struct ftrace_event_call __used                                                \
@@ -166,7 +167,6 @@ __attribute__((section("_ftrace_events"))) event_##call = {         \
        .name                   = #call,                                \
        .id                     = type,                                 \
        .class                  = &event_class_ftrace_##call,           \
-       .raw_init               = ftrace_raw_init_event,                \
        .print_fmt              = print,                                \
 };                                                                     \
 
index b14bf745356f9630920530e0ceaf7ddeda6ed317..428f4a52de69bb0558f15cfac702ade15101802a 100644 (file)
@@ -1359,13 +1359,13 @@ static int register_probe_event(struct trace_probe *tp)
        /* Initialize ftrace_event_call */
        if (probe_is_return(tp)) {
                tp->event.trace = print_kretprobe_event;
-               call->raw_init = probe_event_raw_init;
                INIT_LIST_HEAD(&call->class->fields);
+               call->class->raw_init = probe_event_raw_init;
                call->class->define_fields = kretprobe_event_define_fields;
        } else {
-               tp->event.trace = print_kprobe_event;
-               call->raw_init = probe_event_raw_init;
                INIT_LIST_HEAD(&call->class->fields);
+               tp->event.trace = print_kprobe_event;
+               call->class->raw_init = probe_event_raw_init;
                call->class->define_fields = kprobe_event_define_fields;
        }
        if (set_print_fmt(tp) < 0)
index cceccf0d2e91a2b5260a6f3d5b62a101893178c1..1c1b9bf3ccc6a5dab2df863917ebe0036fcc10e5 100644 (file)
@@ -44,6 +44,7 @@ struct ftrace_event_class event_class_syscall_enter = {
        .reg                    = syscall_enter_register,
        .define_fields          = syscall_enter_define_fields,
        .get_fields             = syscall_get_enter_fields,
+       .raw_init               = init_syscall_trace,
 };
 
 struct ftrace_event_class event_class_syscall_exit = {
@@ -51,6 +52,7 @@ struct ftrace_event_class event_class_syscall_exit = {
        .reg                    = syscall_exit_register,
        .define_fields          = syscall_exit_define_fields,
        .get_fields             = syscall_get_exit_fields,
+       .raw_init               = init_syscall_trace,
 };
 
 extern unsigned long __start_syscalls_metadata[];