提交 2fc5f0cf 编写于 作者: L Li Zefan 提交者: Ingo Molnar

trace_stack: Simplify seqfile code

Extract duplicate code in t_start() and t_next().
Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A891A91.4030602@cn.fujitsu.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 97d53202
...@@ -186,43 +186,33 @@ static const struct file_operations stack_max_size_fops = { ...@@ -186,43 +186,33 @@ static const struct file_operations stack_max_size_fops = {
}; };
static void * static void *
t_next(struct seq_file *m, void *v, loff_t *pos) __next(struct seq_file *m, loff_t *pos)
{ {
long i; long n = *pos - 1;
(*pos)++; if (n >= max_stack_trace.nr_entries || stack_dump_trace[n] == ULONG_MAX)
if (v == SEQ_START_TOKEN)
i = 0;
else {
i = *(long *)v;
i++;
}
if (i >= max_stack_trace.nr_entries ||
stack_dump_trace[i] == ULONG_MAX)
return NULL; return NULL;
m->private = (void *)i; m->private = (void *)n;
return &m->private; return &m->private;
} }
static void *t_start(struct seq_file *m, loff_t *pos) static void *
t_next(struct seq_file *m, void *v, loff_t *pos)
{ {
void *t = SEQ_START_TOKEN; (*pos)++;
loff_t l = 0; return __next(m, pos);
}
static void *t_start(struct seq_file *m, loff_t *pos)
{
local_irq_disable(); local_irq_disable();
__raw_spin_lock(&max_stack_lock); __raw_spin_lock(&max_stack_lock);
if (*pos == 0) if (*pos == 0)
return SEQ_START_TOKEN; return SEQ_START_TOKEN;
for (; t && l < *pos; t = t_next(m, t, &l)) return __next(m, pos);
;
return t;
} }
static void t_stop(struct seq_file *m, void *p) static void t_stop(struct seq_file *m, void *p)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册