diff options
author | Michal Simek <monstr@monstr.eu> | 2009-11-16 04:34:15 -0500 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2009-12-14 02:44:54 -0500 |
commit | 4f911b0daf0f7028a4fe792b701a48d10da36d84 (patch) | |
tree | 746315895bc446df02b1d7e2c1b70550468cab28 | |
parent | a0d3e66522e8f6119f002cf31e5d92d7ae73b409 (diff) |
microblaze: ftrace: Add dynamic function graph tracer
This patch add support for dynamic function graph tracer.
There is one my expactation that I can do flush_icache after
all code modification. On microblaze is this safer than do
flush for every entry. For icache is used name flush but
correct should be invalidation - this will be fix in upcomming
new cache implementaion and WB support.
Signed-off-by: Michal Simek <monstr@monstr.eu>
-rw-r--r-- | arch/microblaze/kernel/ftrace.c | 28 | ||||
-rw-r--r-- | arch/microblaze/kernel/mcount.S | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c index 0952a8b52c35..388b31ca65a1 100644 --- a/arch/microblaze/kernel/ftrace.c +++ b/arch/microblaze/kernel/ftrace.c | |||
@@ -206,4 +206,32 @@ int ftrace_update_ftrace_func(ftrace_func_t func) | |||
206 | return ret; | 206 | return ret; |
207 | } | 207 | } |
208 | 208 | ||
209 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
210 | unsigned int old_jump; /* saving place for jump instruction */ | ||
211 | |||
212 | int ftrace_enable_ftrace_graph_caller(void) | ||
213 | { | ||
214 | unsigned int ret; | ||
215 | unsigned long ip = (unsigned long)(&ftrace_call_graph); | ||
216 | |||
217 | old_jump = *(unsigned int *)ip; /* save jump over instruction */ | ||
218 | ret = ftrace_modify_code(ip, MICROBLAZE_NOP); | ||
219 | flush_icache(); | ||
220 | |||
221 | pr_debug("%s: Replace instruction: 0x%x\n", __func__, old_jump); | ||
222 | return ret; | ||
223 | } | ||
224 | |||
225 | int ftrace_disable_ftrace_graph_caller(void) | ||
226 | { | ||
227 | unsigned int ret; | ||
228 | unsigned long ip = (unsigned long)(&ftrace_call_graph); | ||
229 | |||
230 | ret = ftrace_modify_code(ip, old_jump); | ||
231 | flush_icache(); | ||
232 | |||
233 | pr_debug("%s\n", __func__); | ||
234 | return ret; | ||
235 | } | ||
236 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | ||
209 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 237 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
diff --git a/arch/microblaze/kernel/mcount.S b/arch/microblaze/kernel/mcount.S index 84a19458c74d..e7eaa7a8cbd3 100644 --- a/arch/microblaze/kernel/mcount.S +++ b/arch/microblaze/kernel/mcount.S | |||
@@ -97,6 +97,7 @@ ENTRY(ftrace_caller) | |||
97 | nop; | 97 | nop; |
98 | /* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST end of checking */ | 98 | /* MS: HAVE_FUNCTION_TRACE_MCOUNT_TEST end of checking */ |
99 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 99 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
100 | #ifndef CONFIG_DYNAMIC_FTRACE | ||
100 | lwi r5, r0, ftrace_graph_return; | 101 | lwi r5, r0, ftrace_graph_return; |
101 | addik r6, r0, ftrace_stub; /* asm implementation */ | 102 | addik r6, r0, ftrace_stub; /* asm implementation */ |
102 | cmpu r5, r5, r6; /* ftrace_graph_return != ftrace_stub */ | 103 | cmpu r5, r5, r6; /* ftrace_graph_return != ftrace_stub */ |
@@ -108,6 +109,11 @@ ENTRY(ftrace_caller) | |||
108 | cmpu r5, r5, r6; /* ftrace_graph_entry != ftrace_graph_entry_stub */ | 109 | cmpu r5, r5, r6; /* ftrace_graph_entry != ftrace_graph_entry_stub */ |
109 | beqid r5, end_graph_tracer; | 110 | beqid r5, end_graph_tracer; |
110 | nop; | 111 | nop; |
112 | #else /* CONFIG_DYNAMIC_FTRACE */ | ||
113 | NOALIGN_ENTRY(ftrace_call_graph) | ||
114 | /* MS: jump over graph function - replaced from C code */ | ||
115 | bri end_graph_tracer | ||
116 | #endif /* CONFIG_DYNAMIC_FTRACE */ | ||
111 | addik r5, r1, 120; /* MS: load parent addr */ | 117 | addik r5, r1, 120; /* MS: load parent addr */ |
112 | addik r6, r15, 0; /* MS: load current function addr */ | 118 | addik r6, r15, 0; /* MS: load current function addr */ |
113 | bralid r15, prepare_ftrace_return; | 119 | bralid r15, prepare_ftrace_return; |