From: Steven Rostedt Date: Thu, 22 Apr 2010 14:35:55 +0000 (-0400) Subject: tracing: Move fields from event to class structure X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2e33af029556cb8bd22bf4f86f42d540249177ea;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git tracing: Move fields from event to class structure Move the defined fields from the event to the class structure. Since the fields of the event are defined by the class they belong to, it makes sense to have the class hold the information instead of the individual events. The events of the same class would just hold duplicate information. After this change the size of the kernel dropped another 3K: text data bss dec hex filename 4913961 1088356 861512 6863829 68bbd5 vmlinux.orig 4900252 1057412 861512 6819176 680d68 vmlinux.regs 4900375 1053380 861512 6815267 67fe23 vmlinux.fields Although the text increased, this was mainly due to the C files having to adapt to the change. This is a constant increase, where new tracepoints will not increase the Text. But the big drop is in the data size (as well as needed allocations to hold the fields). This will give even more savings as more tracepoints are created. Note, if just TRACE_EVENT()s are used and not DECLARE_EVENT_CLASS() with several DEFINE_EVENT()s, then the savings will be lost. But we are pushing developers to consolidate events with DEFINE_EVENT() so this should not be an issue. The kprobes define a unique class to every new event, but are dynamic so it should not be a issue. The syscalls however have a single class but the fields for the individual events are different. The syscalls use a metadata to define the fields. I moved the fields list from the event to the metadata and added a "get_fields()" function to the class. This function is used to find the fields. For normal events and kprobes, get_fields() just returns a pointer to the fields list_head in the class. For syscall events, it returns the fields list_head in the metadata for the event. v2: Fixed the syscall fields. The syscall metadata needs a list of fields for both enter and exit. Acked-by: Frederic Weisbecker Acked-by: Mathieu Desnoyers Acked-by: Masami Hiramatsu Cc: Tom Zanussi Cc: Peter Zijlstra Signed-off-by: Steven Rostedt --- diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index e665ed38b4b..479c3c1876e 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h @@ -130,6 +130,9 @@ struct ftrace_event_class { #endif int (*reg)(struct ftrace_event_call *event, enum trace_reg type); + int (*define_fields)(struct ftrace_event_call *); + struct list_head *(*get_fields)(struct ftrace_event_call *); + struct list_head fields; }; struct ftrace_event_call { @@ -142,8 +145,6 @@ struct ftrace_event_call { int id; const char *print_fmt; int (*raw_init)(struct ftrace_event_call *); - int (*define_fields)(struct ftrace_event_call *); - struct list_head fields; int filter_active; struct event_filter *filter; void *mod; diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index e3348c4c22e..fd0f1f248cd 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -122,7 +122,7 @@ extern struct ftrace_event_class event_class_syscall_enter; extern struct ftrace_event_class event_class_syscall_exit; #define SYSCALL_TRACE_ENTER_EVENT(sname) \ - static const struct syscall_metadata __syscall_meta_##sname; \ + static struct syscall_metadata __syscall_meta_##sname; \ static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_enter_##sname; \ static struct trace_event enter_syscall_print_##sname = { \ @@ -136,12 +136,11 @@ extern struct ftrace_event_class event_class_syscall_exit; .class = &event_class_syscall_enter, \ .event = &enter_syscall_print_##sname, \ .raw_init = init_syscall_trace, \ - .define_fields = syscall_enter_define_fields, \ .data = (void *)&__syscall_meta_##sname,\ } #define SYSCALL_TRACE_EXIT_EVENT(sname) \ - static const struct syscall_metadata __syscall_meta_##sname; \ + static struct syscall_metadata __syscall_meta_##sname; \ static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_exit_##sname; \ static struct trace_event exit_syscall_print_##sname = { \ @@ -155,14 +154,13 @@ extern struct ftrace_event_class event_class_syscall_exit; .class = &event_class_syscall_exit, \ .event = &exit_syscall_print_##sname, \ .raw_init = init_syscall_trace, \ - .define_fields = syscall_exit_define_fields, \ .data = (void *)&__syscall_meta_##sname,\ } #define SYSCALL_METADATA(sname, nb) \ SYSCALL_TRACE_ENTER_EVENT(sname); \ SYSCALL_TRACE_EXIT_EVENT(sname); \ - static const struct syscall_metadata __used \ + static struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta_##sname = { \ @@ -172,12 +170,14 @@ extern struct ftrace_event_class event_class_syscall_exit; .args = args_##sname, \ .enter_event = &event_enter_##sname, \ .exit_event = &event_exit_##sname, \ + .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \ + .exit_fields = LIST_HEAD_INIT(__syscall_meta_##sname.exit_fields), \ }; #define SYSCALL_DEFINE0(sname) \ SYSCALL_TRACE_ENTER_EVENT(_##sname); \ SYSCALL_TRACE_EXIT_EVENT(_##sname); \ - static const struct syscall_metadata __used \ + static struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta__##sname = { \ @@ -185,6 +185,8 @@ extern struct ftrace_event_class event_class_syscall_exit; .nb_args = 0, \ .enter_event = &event_enter__##sname, \ .exit_event = &event_exit__##sname, \ + .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \ + .exit_fields = LIST_HEAD_INIT(__syscall_meta__##sname.exit_fields), \ }; \ asmlinkage long sys_##sname(void) #else diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 26d132418f9..c7e3bcd5d52 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -430,6 +430,9 @@ static inline notrace int ftrace_get_offsets_##call( \ * * static struct ftrace_event_class __used event_class_