aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_stack.c')
-rw-r--r--kernel/trace/trace_stack.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index be682b62fe58..fde3be15c642 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -107,8 +107,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
107 if (unlikely(!ftrace_enabled || stack_trace_disabled)) 107 if (unlikely(!ftrace_enabled || stack_trace_disabled))
108 return; 108 return;
109 109
110 resched = need_resched(); 110 resched = ftrace_preempt_disable();
111 preempt_disable_notrace();
112 111
113 cpu = raw_smp_processor_id(); 112 cpu = raw_smp_processor_id();
114 /* no atomic needed, we only modify this variable by this cpu */ 113 /* no atomic needed, we only modify this variable by this cpu */
@@ -120,10 +119,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
120 out: 119 out:
121 per_cpu(trace_active, cpu)--; 120 per_cpu(trace_active, cpu)--;
122 /* prevent recursion in schedule */ 121 /* prevent recursion in schedule */
123 if (resched) 122 ftrace_preempt_enable(resched);
124 preempt_enable_no_resched_notrace();
125 else
126 preempt_enable_notrace();
127} 123}
128 124
129static struct ftrace_ops trace_ops __read_mostly = 125static struct ftrace_ops trace_ops __read_mostly =
@@ -184,11 +180,16 @@ static struct file_operations stack_max_size_fops = {
184static void * 180static void *
185t_next(struct seq_file *m, void *v, loff_t *pos) 181t_next(struct seq_file *m, void *v, loff_t *pos)
186{ 182{
187 long i = (long)m->private; 183 long i;
188 184
189 (*pos)++; 185 (*pos)++;
190 186
191 i++; 187 if (v == SEQ_START_TOKEN)
188 i = 0;
189 else {
190 i = *(long *)v;
191 i++;
192 }
192 193
193 if (i >= max_stack_trace.nr_entries || 194 if (i >= max_stack_trace.nr_entries ||
194 stack_dump_trace[i] == ULONG_MAX) 195 stack_dump_trace[i] == ULONG_MAX)
@@ -201,12 +202,15 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
201 202
202static void *t_start(struct seq_file *m, loff_t *pos) 203static void *t_start(struct seq_file *m, loff_t *pos)
203{ 204{
204 void *t = &m->private; 205 void *t = SEQ_START_TOKEN;
205 loff_t l = 0; 206 loff_t l = 0;
206 207
207 local_irq_disable(); 208 local_irq_disable();
208 __raw_spin_lock(&max_stack_lock); 209 __raw_spin_lock(&max_stack_lock);
209 210
211 if (*pos == 0)
212 return SEQ_START_TOKEN;
213
210 for (; t && l < *pos; t = t_next(m, t, &l)) 214 for (; t && l < *pos; t = t_next(m, t, &l))
211 ; 215 ;
212 216
@@ -235,10 +239,10 @@ static int trace_lookup_stack(struct seq_file *m, long i)
235 239
236static int t_show(struct seq_file *m, void *v) 240static int t_show(struct seq_file *m, void *v)
237{ 241{
238 long i = *(long *)v; 242 long i;
239 int size; 243 int size;
240 244
241 if (i < 0) { 245 if (v == SEQ_START_TOKEN) {
242 seq_printf(m, " Depth Size Location" 246 seq_printf(m, " Depth Size Location"
243 " (%d entries)\n" 247 " (%d entries)\n"
244 " ----- ---- --------\n", 248 " ----- ---- --------\n",
@@ -246,6 +250,8 @@ static int t_show(struct seq_file *m, void *v)
246 return 0; 250 return 0;
247 } 251 }
248 252
253 i = *(long *)v;
254
249 if (i >= max_stack_trace.nr_entries || 255 if (i >= max_stack_trace.nr_entries ||
250 stack_dump_trace[i] == ULONG_MAX) 256 stack_dump_trace[i] == ULONG_MAX)
251 return 0; 257 return 0;
@@ -275,10 +281,6 @@ static int stack_trace_open(struct inode *inode, struct file *file)
275 int ret; 281 int ret;
276 282
277 ret = seq_open(file, &stack_trace_seq_ops); 283 ret = seq_open(file, &stack_trace_seq_ops);
278 if (!ret) {
279 struct seq_file *m = file->private_data;
280 m->private = (void *)-1;
281 }
282 284
283 return ret; 285 return ret;
284} 286}