aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-04-24 22:32:06 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-05-16 19:58:44 -0400
commit9fd49328fc2a1cbfea542bcbcf004b5c81dc495b (patch)
treeda8f42d3483da2b1b224d422db074cbe954b5cd3
parent71babb2705e2203a64c27ede13ae3508a0d2c16c (diff)
ftrace: Sort all function addresses, not just per page
Instead of just sorting the ip's of the functions per ftrace page, sort the entire list before adding them to the ftrace pages. This will allow the bsearch algorithm to be sped up as it can also sort by pages, not just records within a page. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--include/asm-generic/vmlinux.lds.h2
-rw-r--r--kernel/trace/ftrace.c34
2 files changed, 23 insertions, 13 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 8aeadf6b553a..4e2e1cc505ab 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -486,8 +486,8 @@
486 CPU_DISCARD(init.data) \ 486 CPU_DISCARD(init.data) \
487 MEM_DISCARD(init.data) \ 487 MEM_DISCARD(init.data) \
488 KERNEL_CTORS() \ 488 KERNEL_CTORS() \
489 *(.init.rodata) \
490 MCOUNT_REC() \ 489 MCOUNT_REC() \
490 *(.init.rodata) \
491 FTRACE_EVENTS() \ 491 FTRACE_EVENTS() \
492 TRACE_SYSCALLS() \ 492 TRACE_SYSCALLS() \
493 DEV_DISCARD(init.rodata) \ 493 DEV_DISCARD(init.rodata) \
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index cf81f27ce6c6..53ed01ed7aa7 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3666,15 +3666,27 @@ static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer)
3666 return 0; 3666 return 0;
3667} 3667}
3668 3668
3669static void ftrace_swap_recs(void *a, void *b, int size) 3669static int ftrace_cmp_ips(const void *a, const void *b)
3670{ 3670{
3671 struct dyn_ftrace *reca = a; 3671 const unsigned long *ipa = a;
3672 struct dyn_ftrace *recb = b; 3672 const unsigned long *ipb = b;
3673 struct dyn_ftrace t;
3674 3673
3675 t = *reca; 3674 if (*ipa > *ipb)
3676 *reca = *recb; 3675 return 1;
3677 *recb = t; 3676 if (*ipa < *ipb)
3677 return -1;
3678 return 0;
3679}
3680
3681static void ftrace_swap_ips(void *a, void *b, int size)
3682{
3683 unsigned long *ipa = a;
3684 unsigned long *ipb = b;
3685 unsigned long t;
3686
3687 t = *ipa;
3688 *ipa = *ipb;
3689 *ipb = t;
3678} 3690}
3679 3691
3680static int ftrace_process_locs(struct module *mod, 3692static int ftrace_process_locs(struct module *mod,
@@ -3693,6 +3705,9 @@ static int ftrace_process_locs(struct module *mod,
3693 if (!count) 3705 if (!count)
3694 return 0; 3706 return 0;
3695 3707
3708 sort(start, count, sizeof(*start),
3709 ftrace_cmp_ips, ftrace_swap_ips);
3710
3696 pg = ftrace_allocate_pages(count); 3711 pg = ftrace_allocate_pages(count);
3697 if (!pg) 3712 if (!pg)
3698 return -ENOMEM; 3713 return -ENOMEM;
@@ -3740,11 +3755,6 @@ static int ftrace_process_locs(struct module *mod,
3740 /* These new locations need to be initialized */ 3755 /* These new locations need to be initialized */
3741 ftrace_new_pgs = pg; 3756 ftrace_new_pgs = pg;
3742 3757
3743 /* Make each individual set of pages sorted by ips */
3744 for (; pg; pg = pg->next)
3745 sort(pg->records, pg->index, sizeof(struct dyn_ftrace),
3746 ftrace_cmp_recs, ftrace_swap_recs);
3747
3748 /* 3758 /*
3749 * We only need to disable interrupts on start up 3759 * We only need to disable interrupts on start up
3750 * because we are modifying code that an interrupt 3760 * because we are modifying code that an interrupt