Commit d82d62444f87e5993af2fa82ed636b2206e052ea

Authored by Li Zefan
Committed by Ingo Molnar
1 parent 694ce0a544

ftrace: Fix t_hash_start()

When the output of set_ftrace_filter is larger than PAGE_SIZE,
t_hash_start() will be called the 2nd time, and then we start
from the head of a hlist, which is wrong and causes some entries
to be outputed twice.

The worse is, if the hlist is large enough, reading set_ftrace_filter
won't stop but in a dead loop.

Reviewed-by: Liming Wang <liming.wang@windriver.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A41876E.2060407@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 11 additions and 1 deletions Side-by-side Diff

kernel/trace/ftrace.c
... ... @@ -1417,10 +1417,20 @@
1417 1417 {
1418 1418 struct ftrace_iterator *iter = m->private;
1419 1419 void *p = NULL;
  1420 + loff_t l;
1420 1421  
  1422 + if (!(iter->flags & FTRACE_ITER_HASH))
  1423 + *pos = 0;
  1424 +
1421 1425 iter->flags |= FTRACE_ITER_HASH;
1422 1426  
1423   - return t_hash_next(m, p, pos);
  1427 + iter->hidx = 0;
  1428 + for (l = 0; l <= *pos; ) {
  1429 + p = t_hash_next(m, p, &l);
  1430 + if (!p)
  1431 + break;
  1432 + }
  1433 + return p;
1424 1434 }
1425 1435  
1426 1436 static int t_hash_show(struct seq_file *m, void *v)