Commit 85951842a1020669f0a9eb0f0d1853b41341f097
Committed by
Ingo Molnar
1 parent
f129e965be
ftrace: Don't increment @pos in g_start()
It's wrong to increment @pos in g_start(). It causes some entries lost when reading set_graph_function, if the output of the file is larger than PAGE_SIZE. 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: <4A418738.7090401@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 10 additions and 11 deletions Side-by-side Diff
kernel/trace/ftrace.c
... | ... | @@ -2500,32 +2500,31 @@ |
2500 | 2500 | unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly; |
2501 | 2501 | |
2502 | 2502 | static void * |
2503 | -g_next(struct seq_file *m, void *v, loff_t *pos) | |
2503 | +__g_next(struct seq_file *m, loff_t *pos) | |
2504 | 2504 | { |
2505 | 2505 | unsigned long *array = m->private; |
2506 | - int index = *pos; | |
2507 | 2506 | |
2508 | - (*pos)++; | |
2509 | - | |
2510 | - if (index >= ftrace_graph_count) | |
2507 | + if (*pos >= ftrace_graph_count) | |
2511 | 2508 | return NULL; |
2509 | + return &array[*pos]; | |
2510 | +} | |
2512 | 2511 | |
2513 | - return &array[index]; | |
2512 | +static void * | |
2513 | +g_next(struct seq_file *m, void *v, loff_t *pos) | |
2514 | +{ | |
2515 | + (*pos)++; | |
2516 | + return __g_next(m, pos); | |
2514 | 2517 | } |
2515 | 2518 | |
2516 | 2519 | static void *g_start(struct seq_file *m, loff_t *pos) |
2517 | 2520 | { |
2518 | - void *p = NULL; | |
2519 | - | |
2520 | 2521 | mutex_lock(&graph_lock); |
2521 | 2522 | |
2522 | 2523 | /* Nothing, tell g_show to print all functions are enabled */ |
2523 | 2524 | if (!ftrace_graph_count && !*pos) |
2524 | 2525 | return (void *)1; |
2525 | 2526 | |
2526 | - p = g_next(m, p, pos); | |
2527 | - | |
2528 | - return p; | |
2527 | + return __g_next(m, pos); | |
2529 | 2528 | } |
2530 | 2529 | |
2531 | 2530 | static void g_stop(struct seq_file *m, void *p) |