aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/entry_32.S5
-rw-r--r--arch/x86/kernel/ftrace.c44
-rw-r--r--kernel/trace/ring_buffer.c8
-rw-r--r--scripts/bootgraph.pl4
4 files changed, 15 insertions, 46 deletions
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 9a0ac85946db..f97621149839 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1217,12 +1217,9 @@ trace_return:
1217 pushl %eax 1217 pushl %eax
1218 pushl %ecx 1218 pushl %ecx
1219 pushl %edx 1219 pushl %edx
1220 movl 0xc(%esp), %eax 1220 movl 0xc(%esp), %edx
1221 pushl %eax
1222 lea 0x4(%ebp), %eax 1221 lea 0x4(%ebp), %eax
1223 pushl %eax
1224 call prepare_ftrace_return 1222 call prepare_ftrace_return
1225 addl $8, %esp
1226 popl %edx 1223 popl %edx
1227 popl %ecx 1224 popl %ecx
1228 popl %eax 1225 popl %eax
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 16a571dea2ef..fe832738e1e2 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -44,62 +44,37 @@ void ftrace_nmi_exit(void)
44 atomic_dec(&in_nmi); 44 atomic_dec(&in_nmi);
45} 45}
46 46
47/*
48 * Synchronize accesses to return adresses stack with
49 * interrupts.
50 */
51static raw_spinlock_t ret_stack_lock;
52
53/* Add a function return address to the trace stack on thread info.*/ 47/* Add a function return address to the trace stack on thread info.*/
54static int push_return_trace(unsigned long ret, unsigned long long time, 48static int push_return_trace(unsigned long ret, unsigned long long time,
55 unsigned long func) 49 unsigned long func)
56{ 50{
57 int index; 51 int index;
58 struct thread_info *ti; 52 struct thread_info *ti = current_thread_info();
59 unsigned long flags;
60 int err = 0;
61
62 raw_local_irq_save(flags);
63 __raw_spin_lock(&ret_stack_lock);
64 53
65 ti = current_thread_info();
66 /* The return trace stack is full */ 54 /* The return trace stack is full */
67 if (ti->curr_ret_stack == FTRACE_RET_STACK_SIZE - 1) { 55 if (ti->curr_ret_stack == FTRACE_RET_STACK_SIZE - 1)
68 err = -EBUSY; 56 return -EBUSY;
69 goto out;
70 }
71 57
72 index = ++ti->curr_ret_stack; 58 index = ++ti->curr_ret_stack;
73 ti->ret_stack[index].ret = ret; 59 ti->ret_stack[index].ret = ret;
74 ti->ret_stack[index].func = func; 60 ti->ret_stack[index].func = func;
75 ti->ret_stack[index].calltime = time; 61 ti->ret_stack[index].calltime = time;
76 62
77out: 63 return 0;
78 __raw_spin_unlock(&ret_stack_lock);
79 raw_local_irq_restore(flags);
80 return err;
81} 64}
82 65
83/* Retrieve a function return address to the trace stack on thread info.*/ 66/* Retrieve a function return address to the trace stack on thread info.*/
84static void pop_return_trace(unsigned long *ret, unsigned long long *time, 67static void pop_return_trace(unsigned long *ret, unsigned long long *time,
85 unsigned long *func) 68 unsigned long *func)
86{ 69{
87 struct thread_info *ti;
88 int index; 70 int index;
89 unsigned long flags;
90
91 raw_local_irq_save(flags);
92 __raw_spin_lock(&ret_stack_lock);
93 71
94 ti = current_thread_info(); 72 struct thread_info *ti = current_thread_info();
95 index = ti->curr_ret_stack; 73 index = ti->curr_ret_stack;
96 *ret = ti->ret_stack[index].ret; 74 *ret = ti->ret_stack[index].ret;
97 *func = ti->ret_stack[index].func; 75 *func = ti->ret_stack[index].func;
98 *time = ti->ret_stack[index].calltime; 76 *time = ti->ret_stack[index].calltime;
99 ti->curr_ret_stack--; 77 ti->curr_ret_stack--;
100
101 __raw_spin_unlock(&ret_stack_lock);
102 raw_local_irq_restore(flags);
103} 78}
104 79
105/* 80/*
@@ -120,7 +95,6 @@ unsigned long ftrace_return_to_handler(void)
120 * Hook the return address and push it in the stack of return addrs 95 * Hook the return address and push it in the stack of return addrs
121 * in current thread info. 96 * in current thread info.
122 */ 97 */
123asmlinkage
124void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) 98void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
125{ 99{
126 unsigned long old; 100 unsigned long old;
@@ -175,14 +149,6 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
175 *parent = old; 149 *parent = old;
176} 150}
177 151
178static int __init init_ftrace_function_return(void)
179{
180 ret_stack_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
181 return 0;
182}
183device_initcall(init_ftrace_function_return);
184
185
186#endif 152#endif
187 153
188#ifdef CONFIG_DYNAMIC_FTRACE 154#ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 86dc353f89b9..2d6c2cf0c3bc 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -53,8 +53,14 @@ void tracing_off(void)
53/* FIXME!!! */ 53/* FIXME!!! */
54u64 ring_buffer_time_stamp(int cpu) 54u64 ring_buffer_time_stamp(int cpu)
55{ 55{
56 u64 time;
57
58 preempt_disable_notrace();
56 /* shift to debug/test normalization and TIME_EXTENTS */ 59 /* shift to debug/test normalization and TIME_EXTENTS */
57 return sched_clock() << DEBUG_SHIFT; 60 time = sched_clock() << DEBUG_SHIFT;
61 preempt_enable_notrace();
62
63 return time;
58} 64}
59 65
60void ring_buffer_normalize_time_stamp(int cpu, u64 *ts) 66void ring_buffer_normalize_time_stamp(int cpu, u64 *ts)
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl
index d2c61efc216f..a8635a10fef2 100644
--- a/scripts/bootgraph.pl
+++ b/scripts/bootgraph.pl
@@ -109,8 +109,8 @@ my $stylecounter = 0;
109my %rows; 109my %rows;
110my $rowscount = 1; 110my $rowscount = 1;
111my @initcalls = sort { $start{$a} <=> $start{$b} } keys(%start); 111my @initcalls = sort { $start{$a} <=> $start{$b} } keys(%start);
112my $key; 112
113foreach $key (@initcalls) { 113foreach my $key (@initcalls) {
114 my $duration = $end{$key} - $start{$key}; 114 my $duration = $end{$key} - $start{$key};
115 115
116 if ($duration >= $threshold) { 116 if ($duration >= $threshold) {