aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwalimis <walimisdev@gmail.com>2008-11-15 02:19:06 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-16 02:32:05 -0500
commit5821e1b74f0d08952cb5da4bfd2d9a388d8df58e (patch)
treee7bade7c500b2d4cd4d8c811a26c844c6f529366
parentee51a1de7e3837577412be269e0100038068e691 (diff)
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: walimis <walimisdev@gmail.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--kernel/trace/ftrace.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 14fa52297b28..e60205722d0c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -673,7 +673,7 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init)
673 673
674 cnt = num_to_init / ENTRIES_PER_PAGE; 674 cnt = num_to_init / ENTRIES_PER_PAGE;
675 pr_info("ftrace: allocating %ld entries in %d pages\n", 675 pr_info("ftrace: allocating %ld entries in %d pages\n",
676 num_to_init, cnt); 676 num_to_init, cnt + 1);
677 677
678 for (i = 0; i < cnt; i++) { 678 for (i = 0; i < cnt; i++) {
679 pg->next = (void *)get_zeroed_page(GFP_KERNEL); 679 pg->next = (void *)get_zeroed_page(GFP_KERNEL);
@@ -753,13 +753,11 @@ static void *t_start(struct seq_file *m, loff_t *pos)
753 void *p = NULL; 753 void *p = NULL;
754 loff_t l = -1; 754 loff_t l = -1;
755 755
756 if (*pos != iter->pos) { 756 if (*pos > iter->pos)
757 for (p = t_next(m, p, &l); p && l < *pos; p = t_next(m, p, &l)) 757 *pos = iter->pos;
758 ; 758
759 } else { 759 l = *pos;
760 l = *pos; 760 p = t_next(m, p, &l);
761 p = t_next(m, p, &l);
762 }
763 761
764 return p; 762 return p;
765} 763}
@@ -770,15 +768,21 @@ static void t_stop(struct seq_file *m, void *p)
770 768
771static int t_show(struct seq_file *m, void *v) 769static int t_show(struct seq_file *m, void *v)
772{ 770{
771 struct ftrace_iterator *iter = m->private;
773 struct dyn_ftrace *rec = v; 772 struct dyn_ftrace *rec = v;
774 char str[KSYM_SYMBOL_LEN]; 773 char str[KSYM_SYMBOL_LEN];
774 int ret = 0;
775 775
776 if (!rec) 776 if (!rec)
777 return 0; 777 return 0;
778 778
779 kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); 779 kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
780 780
781 seq_printf(m, "%s\n", str); 781 ret = seq_printf(m, "%s\n", str);
782 if (ret < 0) {
783 iter->pos--;
784 iter->idx--;
785 }
782 786
783 return 0; 787 return 0;
784} 788}
@@ -804,7 +808,7 @@ ftrace_avail_open(struct inode *inode, struct file *file)
804 return -ENOMEM; 808 return -ENOMEM;
805 809
806 iter->pg = ftrace_pages_start; 810 iter->pg = ftrace_pages_start;
807 iter->pos = -1; 811 iter->pos = 0;
808 812
809 ret = seq_open(file, &show_ftrace_seq_ops); 813 ret = seq_open(file, &show_ftrace_seq_ops);
810 if (!ret) { 814 if (!ret) {
@@ -891,7 +895,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
891 895
892 if (file->f_mode & FMODE_READ) { 896 if (file->f_mode & FMODE_READ) {
893 iter->pg = ftrace_pages_start; 897 iter->pg = ftrace_pages_start;
894 iter->pos = -1; 898 iter->pos = 0;
895 iter->flags = enable ? FTRACE_ITER_FILTER : 899 iter->flags = enable ? FTRACE_ITER_FILTER :
896 FTRACE_ITER_NOTRACE; 900 FTRACE_ITER_NOTRACE;
897 901