aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-11-26 00:16:24 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-26 00:52:54 -0500
commit5a45cfe1c64862e8cd3b0d79d7c4ba71c3118915 (patch)
tree0a7edf3a9dc88d74b7c7053445ac8aff033a75fa /kernel/trace
parentdf4fc31558dd2a3a30292ddb3a64c2a5befcec73 (diff)
ftrace: use code patching for ftrace graph tracer
Impact: more efficient code for ftrace graph tracer This patch uses the dynamic patching, when available, to patch the function graph code into the kernel. This patch will ease the way for letting both function tracing and function graph tracing run together. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ftrace.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 00d98c65fad0..5f7c8642d58b 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -281,6 +281,8 @@ enum {
281 FTRACE_UPDATE_TRACE_FUNC = (1 << 2), 281 FTRACE_UPDATE_TRACE_FUNC = (1 << 2),
282 FTRACE_ENABLE_MCOUNT = (1 << 3), 282 FTRACE_ENABLE_MCOUNT = (1 << 3),
283 FTRACE_DISABLE_MCOUNT = (1 << 4), 283 FTRACE_DISABLE_MCOUNT = (1 << 4),
284 FTRACE_START_FUNC_RET = (1 << 5),
285 FTRACE_STOP_FUNC_RET = (1 << 6),
284}; 286};
285 287
286static int ftrace_filtered; 288static int ftrace_filtered;
@@ -465,14 +467,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
465 unsigned long ip, fl; 467 unsigned long ip, fl;
466 unsigned long ftrace_addr; 468 unsigned long ftrace_addr;
467 469
468#ifdef CONFIG_FUNCTION_GRAPH_TRACER
469 if (ftrace_tracing_type == FTRACE_TYPE_ENTER)
470 ftrace_addr = (unsigned long)ftrace_caller;
471 else
472 ftrace_addr = (unsigned long)ftrace_graph_caller;
473#else
474 ftrace_addr = (unsigned long)ftrace_caller; 470 ftrace_addr = (unsigned long)ftrace_caller;
475#endif
476 471
477 ip = rec->ip; 472 ip = rec->ip;
478 473
@@ -605,6 +600,11 @@ static int __ftrace_modify_code(void *data)
605 if (*command & FTRACE_UPDATE_TRACE_FUNC) 600 if (*command & FTRACE_UPDATE_TRACE_FUNC)
606 ftrace_update_ftrace_func(ftrace_trace_function); 601 ftrace_update_ftrace_func(ftrace_trace_function);
607 602
603 if (*command & FTRACE_START_FUNC_RET)
604 ftrace_enable_ftrace_graph_caller();
605 else if (*command & FTRACE_STOP_FUNC_RET)
606 ftrace_disable_ftrace_graph_caller();
607
608 return 0; 608 return 0;
609} 609}
610 610
@@ -629,10 +629,8 @@ static void ftrace_startup_enable(int command)
629 ftrace_run_update_code(command); 629 ftrace_run_update_code(command);
630} 630}
631 631
632static void ftrace_startup(void) 632static void ftrace_startup(int command)
633{ 633{
634 int command = 0;
635
636 if (unlikely(ftrace_disabled)) 634 if (unlikely(ftrace_disabled))
637 return; 635 return;
638 636
@@ -645,10 +643,8 @@ static void ftrace_startup(void)
645 mutex_unlock(&ftrace_start_lock); 643 mutex_unlock(&ftrace_start_lock);
646} 644}
647 645
648static void ftrace_shutdown(void) 646static void ftrace_shutdown(int command)
649{ 647{
650 int command = 0;
651
652 if (unlikely(ftrace_disabled)) 648 if (unlikely(ftrace_disabled))
653 return; 649 return;
654 650
@@ -1453,8 +1449,9 @@ device_initcall(ftrace_nodyn_init);
1453 1449
1454static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; } 1450static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; }
1455static inline void ftrace_startup_enable(int command) { } 1451static inline void ftrace_startup_enable(int command) { }
1456# define ftrace_startup() do { } while (0) 1452/* Keep as macros so we do not need to define the commands */
1457# define ftrace_shutdown() do { } while (0) 1453# define ftrace_startup(command) do { } while (0)
1454# define ftrace_shutdown(command) do { } while (0)
1458# define ftrace_startup_sysctl() do { } while (0) 1455# define ftrace_startup_sysctl() do { } while (0)
1459# define ftrace_shutdown_sysctl() do { } while (0) 1456# define ftrace_shutdown_sysctl() do { } while (0)
1460#endif /* CONFIG_DYNAMIC_FTRACE */ 1457#endif /* CONFIG_DYNAMIC_FTRACE */
@@ -1585,7 +1582,7 @@ int register_ftrace_function(struct ftrace_ops *ops)
1585 } 1582 }
1586 1583
1587 ret = __register_ftrace_function(ops); 1584 ret = __register_ftrace_function(ops);
1588 ftrace_startup(); 1585 ftrace_startup(0);
1589 1586
1590out: 1587out:
1591 mutex_unlock(&ftrace_sysctl_lock); 1588 mutex_unlock(&ftrace_sysctl_lock);
@@ -1604,7 +1601,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
1604 1601
1605 mutex_lock(&ftrace_sysctl_lock); 1602 mutex_lock(&ftrace_sysctl_lock);
1606 ret = __unregister_ftrace_function(ops); 1603 ret = __unregister_ftrace_function(ops);
1607 ftrace_shutdown(); 1604 ftrace_shutdown(0);
1608 mutex_unlock(&ftrace_sysctl_lock); 1605 mutex_unlock(&ftrace_sysctl_lock);
1609 1606
1610 return ret; 1607 return ret;
@@ -1751,7 +1748,7 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
1751 ftrace_tracing_type = FTRACE_TYPE_RETURN; 1748 ftrace_tracing_type = FTRACE_TYPE_RETURN;
1752 ftrace_graph_return = retfunc; 1749 ftrace_graph_return = retfunc;
1753 ftrace_graph_entry = entryfunc; 1750 ftrace_graph_entry = entryfunc;
1754 ftrace_startup(); 1751 ftrace_startup(FTRACE_START_FUNC_RET);
1755 1752
1756out: 1753out:
1757 mutex_unlock(&ftrace_sysctl_lock); 1754 mutex_unlock(&ftrace_sysctl_lock);
@@ -1765,7 +1762,7 @@ void unregister_ftrace_graph(void)
1765 atomic_dec(&ftrace_graph_active); 1762 atomic_dec(&ftrace_graph_active);
1766 ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub; 1763 ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
1767 ftrace_graph_entry = (trace_func_graph_ent_t)ftrace_stub; 1764 ftrace_graph_entry = (trace_func_graph_ent_t)ftrace_stub;
1768 ftrace_shutdown(); 1765 ftrace_shutdown(FTRACE_STOP_FUNC_RET);
1769 /* Restore normal tracing type */ 1766 /* Restore normal tracing type */
1770 ftrace_tracing_type = FTRACE_TYPE_ENTER; 1767 ftrace_tracing_type = FTRACE_TYPE_ENTER;
1771 1768