Commit 694ce0a5 authored by Li Zefan's avatar Li Zefan Committed by Ingo Molnar

ftrace: Don't manipulate @pos in t_start()

It's rather confusing that in t_start(), in some cases @pos is
incremented, and in some cases it's decremented and then incremented.

This patch rewrites t_start() in a much more general way.

Thus we fix a bug that if ftrace_filtered == 1, functions have tracer
hooks won't be printed, because the branch is always unreachable:

static void *t_start(...)
{
	...
	if (!p)
		return t_hash_start(m, pos);
	return p;
}

Before:
  # echo 'sys_open' > /mnt/tracing/set_ftrace_filter
  # echo 'sys_write:traceon:4' >> /mnt/tracing/set_ftrace_filter
  sys_open

After:
  # echo 'sys_open' > /mnt/tracing/set_ftrace_filter
  # echo 'sys_write:traceon:4' >> /mnt/tracing/set_ftrace_filter
  sys_open
  sys_write:traceon:count=4
Reviewed-by: default avatarLiming Wang <liming.wang@windriver.com>
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A41874B.4090507@cn.fujitsu.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 85951842
...@@ -1467,8 +1467,6 @@ t_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -1467,8 +1467,6 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
iter->pg = iter->pg->next; iter->pg = iter->pg->next;
iter->idx = 0; iter->idx = 0;
goto retry; goto retry;
} else {
iter->idx = -1;
} }
} else { } else {
rec = &iter->pg->records[iter->idx++]; rec = &iter->pg->records[iter->idx++];
...@@ -1497,6 +1495,7 @@ static void *t_start(struct seq_file *m, loff_t *pos) ...@@ -1497,6 +1495,7 @@ static void *t_start(struct seq_file *m, loff_t *pos)
{ {
struct ftrace_iterator *iter = m->private; struct ftrace_iterator *iter = m->private;
void *p = NULL; void *p = NULL;
loff_t l;
mutex_lock(&ftrace_lock); mutex_lock(&ftrace_lock);
/* /*
...@@ -1508,23 +1507,21 @@ static void *t_start(struct seq_file *m, loff_t *pos) ...@@ -1508,23 +1507,21 @@ static void *t_start(struct seq_file *m, loff_t *pos)
if (*pos > 0) if (*pos > 0)
return t_hash_start(m, pos); return t_hash_start(m, pos);
iter->flags |= FTRACE_ITER_PRINTALL; iter->flags |= FTRACE_ITER_PRINTALL;
(*pos)++;
return iter; return iter;
} }
if (iter->flags & FTRACE_ITER_HASH) if (iter->flags & FTRACE_ITER_HASH)
return t_hash_start(m, pos); return t_hash_start(m, pos);
if (*pos > 0) { iter->pg = ftrace_pages_start;
if (iter->idx < 0) iter->idx = 0;
return p; for (l = 0; l <= *pos; ) {
(*pos)--; p = t_next(m, p, &l);
iter->idx--; if (!p)
break;
} }
p = t_next(m, p, pos); if (!p && iter->flags & FTRACE_ITER_FILTER)
if (!p)
return t_hash_start(m, pos); return t_hash_start(m, pos);
return p; return p;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment