aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-08-14 22:47:19 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:35:12 -0400
commitfed1939c64d2288938fdc1c367d49082da65e195 (patch)
treea4592352d28efcfe82379c71d061b9127e49a115 /kernel/trace/ftrace.c
parent28614889bcb2558a47d02d52394b7fd9795a9547 (diff)
ftrace: remove old pointers to mcount
When a mcount pointer is recorded into a table, it is used to add or remove calls to mcount (replacing them with nops). If the code is removed via removing a module, the pointers still exist. At modifying the code a check is always made to make sure the code being replaced is the code expected. In-other-words, the code being replaced is compared to what it is expected to be before being replaced. There is a very small chance that the code being replaced just happens to look like code that calls mcount (very small since the call to mcount is relative). To remove this chance, this patch adds ftrace_release to allow module unloading to remove the pointers to mcount within the module. Another change for init calls is made to not trace calls marked with __init. The tracing can not be started until after init is done anyway. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8affb6d00ec1..eadd0eaea9b6 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -294,13 +294,37 @@ static inline void ftrace_del_hash(struct dyn_ftrace *node)
294 294
295static void ftrace_free_rec(struct dyn_ftrace *rec) 295static void ftrace_free_rec(struct dyn_ftrace *rec)
296{ 296{
297 /* no locking, only called from kstop_machine */
298
299 rec->ip = (unsigned long)ftrace_free_records; 297 rec->ip = (unsigned long)ftrace_free_records;
300 ftrace_free_records = rec; 298 ftrace_free_records = rec;
301 rec->flags |= FTRACE_FL_FREE; 299 rec->flags |= FTRACE_FL_FREE;
302} 300}
303 301
302void ftrace_release(void *start, unsigned long size)
303{
304 struct dyn_ftrace *rec;
305 struct ftrace_page *pg;
306 unsigned long s = (unsigned long)start;
307 unsigned long e = s + size;
308 int i;
309
310 if (!start)
311 return;
312
313 /* No interrupt should call this */
314 spin_lock(&ftrace_lock);
315
316 for (pg = ftrace_pages_start; pg; pg = pg->next) {
317 for (i = 0; i < pg->index; i++) {
318 rec = &pg->records[i];
319
320 if ((rec->ip >= s) && (rec->ip < e))
321 ftrace_free_rec(rec);
322 }
323 }
324 spin_unlock(&ftrace_lock);
325
326}
327
304static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip) 328static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip)
305{ 329{
306 struct dyn_ftrace *rec; 330 struct dyn_ftrace *rec;
@@ -1527,7 +1551,9 @@ static int ftrace_convert_nops(unsigned long *start,
1527 p = start; 1551 p = start;
1528 while (p < end) { 1552 while (p < end) {
1529 addr = ftrace_call_adjust(*p++); 1553 addr = ftrace_call_adjust(*p++);
1554 spin_lock(&ftrace_lock);
1530 ftrace_record_ip(addr); 1555 ftrace_record_ip(addr);
1556 spin_unlock(&ftrace_lock);
1531 ftrace_shutdown_replenish(); 1557 ftrace_shutdown_replenish();
1532 } 1558 }
1533 1559
@@ -1541,6 +1567,8 @@ static int ftrace_convert_nops(unsigned long *start,
1541 1567
1542void ftrace_init_module(unsigned long *start, unsigned long *end) 1568void ftrace_init_module(unsigned long *start, unsigned long *end)
1543{ 1569{
1570 if (start == end)
1571 return;
1544 ftrace_convert_nops(start, end); 1572 ftrace_convert_nops(start, end);
1545} 1573}
1546 1574