Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ftrace: Reduce size of function graph entries

Currently ftrace_graph_ent{,_entry} and ftrace_graph_ret{,_entry} struct
can have padding bytes at the end due to alignment in 64-bit data type.
As these data are recorded so frequently, those paddings waste
non-negligible space. As the ring buffer maintains alignment properly
for each architecture, just to remove the extra padding using 'packed'
attribute.

ftrace_graph_ent_entry: 24 -> 20
ftrace_graph_ret_entry: 48 -> 44

Also I moved the 'overrun' field in struct ftrace_graph_ret to minimize
the padding in the middle.

Tested on x86_64 only.

Link: http://lkml.kernel.org/r/1467197808-13578-1-git-send-email-namhyung@kernel.org

Cc: Ingo Molnar <mingo@kernel.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Namhyung Kim and committed by
Steven Rostedt
a4a551b8 7ad8fb61

+21 -6
+8 -4
include/linux/ftrace.h
··· 754 754 755 755 /* 756 756 * Structure that defines an entry function trace. 757 + * It's already packed but the attribute "packed" is needed 758 + * to remove extra padding at the end. 757 759 */ 758 760 struct ftrace_graph_ent { 759 761 unsigned long func; /* Current function */ 760 762 int depth; 761 - }; 763 + } __packed; 762 764 763 765 /* 764 766 * Structure that defines a return function trace. 767 + * It's already packed but the attribute "packed" is needed 768 + * to remove extra padding at the end. 765 769 */ 766 770 struct ftrace_graph_ret { 767 771 unsigned long func; /* Current function */ 768 - unsigned long long calltime; 769 - unsigned long long rettime; 770 772 /* Number of functions that overran the depth limit for current task */ 771 773 unsigned long overrun; 774 + unsigned long long calltime; 775 + unsigned long long rettime; 772 776 int depth; 773 - }; 777 + } __packed; 774 778 775 779 /* Type of the callback handlers for tracing function graph*/ 776 780 typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
+11
kernel/trace/trace.h
··· 80 80 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \ 81 81 filter) 82 82 83 + #undef FTRACE_ENTRY_PACKED 84 + #define FTRACE_ENTRY_PACKED(name, struct_name, id, tstruct, print, \ 85 + filter) \ 86 + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \ 87 + filter) __packed 88 + 83 89 #include "trace_entries.h" 84 90 85 91 /* ··· 1631 1625 #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \ 1632 1626 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \ 1633 1627 filter) 1628 + #undef FTRACE_ENTRY_PACKED 1629 + #define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print, filter) \ 1630 + FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \ 1631 + filter) 1632 + 1634 1633 #include "trace_entries.h" 1635 1634 1636 1635 #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
+2 -2
kernel/trace/trace_entries.h
··· 72 72 ); 73 73 74 74 /* Function call entry */ 75 - FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry, 75 + FTRACE_ENTRY_PACKED(funcgraph_entry, ftrace_graph_ent_entry, 76 76 77 77 TRACE_GRAPH_ENT, 78 78 ··· 88 88 ); 89 89 90 90 /* Function return entry */ 91 - FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry, 91 + FTRACE_ENTRY_PACKED(funcgraph_exit, ftrace_graph_ret_entry, 92 92 93 93 TRACE_GRAPH_RET, 94 94