aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-12-16 17:06:45 -0500
committerSteven Rostedt <rostedt@goodmis.org>2011-12-21 07:19:58 -0500
commit68950619f8c82e468d8976130462617abea605a8 (patch)
tree88a2a4ae266b0bad4335c9bb803b7feb76d71c90 /kernel
parent85ae32ae019bc1c2cc22e5f51fe0c9f2812ef68c (diff)
ftrace: Sort the mcount records on each page
Sort records by ip locations of the ftrace mcount calls on each of the set of pages in the function list. This helps in localizing cache usuage when updating the function locations, as well as gives us the ability to quickly find an ip location in the list. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/ftrace.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 366d7881f188..2d6f8bcd1884 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -27,6 +27,7 @@
27#include <linux/sysctl.h> 27#include <linux/sysctl.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/ctype.h> 29#include <linux/ctype.h>
30#include <linux/sort.h>
30#include <linux/list.h> 31#include <linux/list.h>
31#include <linux/hash.h> 32#include <linux/hash.h>
32#include <linux/rcupdate.h> 33#include <linux/rcupdate.h>
@@ -3575,6 +3576,29 @@ static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer)
3575 return 0; 3576 return 0;
3576} 3577}
3577 3578
3579static void ftrace_swap_recs(void *a, void *b, int size)
3580{
3581 struct dyn_ftrace *reca = a;
3582 struct dyn_ftrace *recb = b;
3583 struct dyn_ftrace t;
3584
3585 t = *reca;
3586 *reca = *recb;
3587 *recb = t;
3588}
3589
3590static int ftrace_cmp_recs(const void *a, const void *b)
3591{
3592 const struct dyn_ftrace *reca = a;
3593 const struct dyn_ftrace *recb = b;
3594
3595 if (reca->ip > recb->ip)
3596 return 1;
3597 if (reca->ip < recb->ip)
3598 return -1;
3599 return 0;
3600}
3601
3578static int ftrace_process_locs(struct module *mod, 3602static int ftrace_process_locs(struct module *mod,
3579 unsigned long *start, 3603 unsigned long *start,
3580 unsigned long *end) 3604 unsigned long *end)
@@ -3638,6 +3662,11 @@ static int ftrace_process_locs(struct module *mod,
3638 /* These new locations need to be initialized */ 3662 /* These new locations need to be initialized */
3639 ftrace_new_pgs = pg; 3663 ftrace_new_pgs = pg;
3640 3664
3665 /* Make each individual set of pages sorted by ips */
3666 for (; pg; pg = pg->next)
3667 sort(pg->records, pg->index, sizeof(struct dyn_ftrace),
3668 ftrace_cmp_recs, ftrace_swap_recs);
3669
3641 /* 3670 /*
3642 * We only need to disable interrupts on start up 3671 * We only need to disable interrupts on start up
3643 * because we are modifying code that an interrupt 3672 * because we are modifying code that an interrupt