Commit 5821e1b7 authored by walimis's avatar walimis Committed by Ingo Molnar

function tracing: fix wrong pos computing when read buffer has been fulfilled

Impact: make output of available_filter_functions complete

phenomenon:

The first value of dyn_ftrace_total_info is not equal with
`cat available_filter_functions | wc -l`, but they should be equal.

root cause:

When printing functions with seq_printf in t_show, if the read buffer
is just overflowed by current function record, then this function
won't be printed to user space through read buffer, it will
just be dropped. So we can't see this function printing.

So, every time the last function to fill the read buffer, if overflowed,
will be dropped.

This also applies to set_ftrace_filter if set_ftrace_filter has
more bytes than read buffer.

fix:

Through checking return value of seq_printf, if less than 0, we know
this function doesn't be printed. Then we decrease position to force
this function to be printed next time, in next read buffer.

Another little fix is to show correct allocating pages count.
Signed-off-by: default avatarwalimis <walimisdev@gmail.com>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent ee51a1de
...@@ -673,7 +673,7 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init) ...@@ -673,7 +673,7 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init)
cnt = num_to_init / ENTRIES_PER_PAGE; cnt = num_to_init / ENTRIES_PER_PAGE;
pr_info("ftrace: allocating %ld entries in %d pages\n", pr_info("ftrace: allocating %ld entries in %d pages\n",
num_to_init, cnt); num_to_init, cnt + 1);
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
pg->next = (void *)get_zeroed_page(GFP_KERNEL); pg->next = (void *)get_zeroed_page(GFP_KERNEL);
...@@ -753,13 +753,11 @@ static void *t_start(struct seq_file *m, loff_t *pos) ...@@ -753,13 +753,11 @@ static void *t_start(struct seq_file *m, loff_t *pos)
void *p = NULL; void *p = NULL;
loff_t l = -1; loff_t l = -1;
if (*pos != iter->pos) { if (*pos > iter->pos)
for (p = t_next(m, p, &l); p && l < *pos; p = t_next(m, p, &l)) *pos = iter->pos;
;
} else {
l = *pos; l = *pos;
p = t_next(m, p, &l); p = t_next(m, p, &l);
}
return p; return p;
} }
...@@ -770,15 +768,21 @@ static void t_stop(struct seq_file *m, void *p) ...@@ -770,15 +768,21 @@ static void t_stop(struct seq_file *m, void *p)
static int t_show(struct seq_file *m, void *v) static int t_show(struct seq_file *m, void *v)
{ {
struct ftrace_iterator *iter = m->private;
struct dyn_ftrace *rec = v; struct dyn_ftrace *rec = v;
char str[KSYM_SYMBOL_LEN]; char str[KSYM_SYMBOL_LEN];
int ret = 0;
if (!rec) if (!rec)
return 0; return 0;
kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
seq_printf(m, "%s\n", str); ret = seq_printf(m, "%s\n", str);
if (ret < 0) {
iter->pos--;
iter->idx--;
}
return 0; return 0;
} }
...@@ -804,7 +808,7 @@ ftrace_avail_open(struct inode *inode, struct file *file) ...@@ -804,7 +808,7 @@ ftrace_avail_open(struct inode *inode, struct file *file)
return -ENOMEM; return -ENOMEM;
iter->pg = ftrace_pages_start; iter->pg = ftrace_pages_start;
iter->pos = -1; iter->pos = 0;
ret = seq_open(file, &show_ftrace_seq_ops); ret = seq_open(file, &show_ftrace_seq_ops);
if (!ret) { if (!ret) {
...@@ -891,7 +895,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable) ...@@ -891,7 +895,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
iter->pg = ftrace_pages_start; iter->pg = ftrace_pages_start;
iter->pos = -1; iter->pos = 0;
iter->flags = enable ? FTRACE_ITER_FILTER : iter->flags = enable ? FTRACE_ITER_FILTER :
FTRACE_ITER_NOTRACE; FTRACE_ITER_NOTRACE;
......
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