aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-06-29 06:56:48 -0400
committerSteven Rostedt <rostedt@goodmis.org>2016-07-05 17:28:30 -0400
commita4a551b8f1d4c4ebffd0f49dfef44df3128546f8 (patch)
treef59e73d2d4265f88018dea61756793eb15797604
parent7ad8fb61c4abf589596f0a4da34d987471481569 (diff)
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>
-rw-r--r--include/linux/ftrace.h12
-rw-r--r--kernel/trace/trace.h11
-rw-r--r--kernel/trace/trace_entries.h4
3 files changed, 21 insertions, 6 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 66a36a815f0a..7d565afe35d2 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -754,23 +754,27 @@ static inline void ftrace_init(void) { }
754 754
755/* 755/*
756 * Structure that defines an entry function trace. 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 */
758struct ftrace_graph_ent { 760struct ftrace_graph_ent {
759 unsigned long func; /* Current function */ 761 unsigned long func; /* Current function */
760 int depth; 762 int depth;
761}; 763} __packed;
762 764
763/* 765/*
764 * Structure that defines a return function trace. 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 */
766struct ftrace_graph_ret { 770struct ftrace_graph_ret {
767 unsigned long func; /* Current function */ 771 unsigned long func; /* Current function */
768 unsigned long long calltime;
769 unsigned long long rettime;
770 /* Number of functions that overran the depth limit for current task */ 772 /* Number of functions that overran the depth limit for current task */
771 unsigned long overrun; 773 unsigned long overrun;
774 unsigned long long calltime;
775 unsigned long long rettime;
772 int depth; 776 int depth;
773}; 777} __packed;
774 778
775/* Type of the callback handlers for tracing function graph*/ 779/* Type of the callback handlers for tracing function graph*/
776typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */ 780typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index c1de3f493cd3..f783df416726 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -80,6 +80,12 @@ enum trace_type {
80 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \ 80 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
81 filter) 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#include "trace_entries.h" 89#include "trace_entries.h"
84 90
85/* 91/*
@@ -1625,6 +1631,11 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
1625#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \ 1631#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
1626 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \ 1632 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
1627 filter) 1633 filter)
1634#undef FTRACE_ENTRY_PACKED
1635#define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print, filter) \
1636 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
1637 filter)
1638
1628#include "trace_entries.h" 1639#include "trace_entries.h"
1629 1640
1630#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER) 1641#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index ee7b94a4810a..5c30efcda5e6 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -72,7 +72,7 @@ FTRACE_ENTRY_REG(function, ftrace_entry,
72); 72);
73 73
74/* Function call entry */ 74/* Function call entry */
75FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry, 75FTRACE_ENTRY_PACKED(funcgraph_entry, ftrace_graph_ent_entry,
76 76
77 TRACE_GRAPH_ENT, 77 TRACE_GRAPH_ENT,
78 78
@@ -88,7 +88,7 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
88); 88);
89 89
90/* Function return entry */ 90/* Function return entry */
91FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry, 91FTRACE_ENTRY_PACKED(funcgraph_exit, ftrace_graph_ret_entry,
92 92
93 TRACE_GRAPH_RET, 93 TRACE_GRAPH_RET,
94 94