aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-07-22 20:41:42 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-09-09 19:26:06 -0400
commit87354059881ce9315181604dc17076c535f4d744 (patch)
treeaaec89b1b94d9ca028a91da44b68a578aa62148a /kernel/trace/ftrace.c
parentf1ff6348b30b3658d138f05643149706f99078ae (diff)
ftrace: Add helper function ftrace_ops_get_func()
Add the helper function to what the mcount trampoline is to call for a ftrace_ops function. This helper will be used by arch code in the future to set up dynamic trampolines. But as this does the same tests that are performed in choosing what function to call for the default mcount trampoline, might as well use it to clean up the existing code. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 17b606362ab4..dabf734f909c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -259,20 +259,12 @@ static void update_ftrace_function(void)
259 * then have the mcount trampoline call the function directly. 259 * then have the mcount trampoline call the function directly.
260 */ 260 */
261 if (ftrace_ops_list == &ftrace_list_end || 261 if (ftrace_ops_list == &ftrace_list_end ||
262 (ftrace_ops_list->next == &ftrace_list_end && 262 (ftrace_ops_list->next == &ftrace_list_end)) {
263 !(ftrace_ops_list->flags & FTRACE_OPS_FL_DYNAMIC) && 263
264 !FTRACE_FORCE_LIST_FUNC)) {
265 /* Set the ftrace_ops that the arch callback uses */ 264 /* Set the ftrace_ops that the arch callback uses */
266 set_function_trace_op = ftrace_ops_list; 265 set_function_trace_op = ftrace_ops_list;
267 /* 266
268 * If the func handles its own recursion, call it directly. 267 func = ftrace_ops_get_func(ftrace_ops_list);
269 * Otherwise call the recursion protected function that
270 * will call the ftrace ops function.
271 */
272 if (ftrace_ops_list->flags & FTRACE_OPS_FL_RECURSION_SAFE)
273 func = ftrace_ops_list->func;
274 else
275 func = ftrace_ops_recurs_func;
276 } else { 268 } else {
277 /* Just use the default ftrace_ops */ 269 /* Just use the default ftrace_ops */
278 set_function_trace_op = &ftrace_list_end; 270 set_function_trace_op = &ftrace_list_end;
@@ -4856,6 +4848,37 @@ static void ftrace_ops_recurs_func(unsigned long ip, unsigned long parent_ip,
4856 trace_clear_recursion(bit); 4848 trace_clear_recursion(bit);
4857} 4849}
4858 4850
4851/**
4852 * ftrace_ops_get_func - get the function a trampoline should call
4853 * @ops: the ops to get the function for
4854 *
4855 * Normally the mcount trampoline will call the ops->func, but there
4856 * are times that it should not. For example, if the ops does not
4857 * have its own recursion protection, then it should call the
4858 * ftrace_ops_recurs_func() instead.
4859 *
4860 * Returns the function that the trampoline should call for @ops.
4861 */
4862ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops)
4863{
4864 /*
4865 * If this is a dynamic ops or we force list func,
4866 * then it needs to call the list anyway.
4867 */
4868 if (ops->flags & FTRACE_OPS_FL_DYNAMIC || FTRACE_FORCE_LIST_FUNC)
4869 return ftrace_ops_list_func;
4870
4871 /*
4872 * If the func handles its own recursion, call it directly.
4873 * Otherwise call the recursion protected function that
4874 * will call the ftrace ops function.
4875 */
4876 if (!(ops->flags & FTRACE_OPS_FL_RECURSION_SAFE))
4877 return ftrace_ops_recurs_func;
4878
4879 return ops->func;
4880}
4881
4859static void clear_ftrace_swapper(void) 4882static void clear_ftrace_swapper(void)
4860{ 4883{
4861 struct task_struct *p; 4884 struct task_struct *p;