diff options
author | Liming Wang <liming.wang@windriver.com> | 2008-11-27 23:13:21 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-28 06:30:40 -0500 |
commit | 50cdaf08a8ec1d7f43987705da7aff7cf949708f (patch) | |
tree | b8c1b6072d907a196df4ef556cf6c0070b289b38 /kernel/trace/ftrace.c | |
parent | c7cc77307669336a08928ab8668bdb3f3bcc021b (diff) |
ftrace: improve seq_operation of ftrace
Impact: make ftrace position computing more sane
First remove useless ->pos field. Then we needn't check seq_printf
in .show like other place.
Signed-off-by: Liming Wang <liming.wang@windriver.com>
Reviewed-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r-- | kernel/trace/ftrace.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index cbf8b09f63a5..08b536a2614e 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -786,7 +786,6 @@ enum { | |||
786 | #define FTRACE_BUFF_MAX (KSYM_SYMBOL_LEN+4) /* room for wildcards */ | 786 | #define FTRACE_BUFF_MAX (KSYM_SYMBOL_LEN+4) /* room for wildcards */ |
787 | 787 | ||
788 | struct ftrace_iterator { | 788 | struct ftrace_iterator { |
789 | loff_t pos; | ||
790 | struct ftrace_page *pg; | 789 | struct ftrace_page *pg; |
791 | unsigned idx; | 790 | unsigned idx; |
792 | unsigned flags; | 791 | unsigned flags; |
@@ -811,6 +810,8 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
811 | iter->pg = iter->pg->next; | 810 | iter->pg = iter->pg->next; |
812 | iter->idx = 0; | 811 | iter->idx = 0; |
813 | goto retry; | 812 | goto retry; |
813 | } else { | ||
814 | iter->idx = -1; | ||
814 | } | 815 | } |
815 | } else { | 816 | } else { |
816 | rec = &iter->pg->records[iter->idx++]; | 817 | rec = &iter->pg->records[iter->idx++]; |
@@ -833,8 +834,6 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
833 | } | 834 | } |
834 | spin_unlock(&ftrace_lock); | 835 | spin_unlock(&ftrace_lock); |
835 | 836 | ||
836 | iter->pos = *pos; | ||
837 | |||
838 | return rec; | 837 | return rec; |
839 | } | 838 | } |
840 | 839 | ||
@@ -842,13 +841,15 @@ static void *t_start(struct seq_file *m, loff_t *pos) | |||
842 | { | 841 | { |
843 | struct ftrace_iterator *iter = m->private; | 842 | struct ftrace_iterator *iter = m->private; |
844 | void *p = NULL; | 843 | void *p = NULL; |
845 | loff_t l = -1; | ||
846 | 844 | ||
847 | if (*pos > iter->pos) | 845 | if (*pos > 0) { |
848 | *pos = iter->pos; | 846 | if (iter->idx < 0) |
847 | return p; | ||
848 | (*pos)--; | ||
849 | iter->idx--; | ||
850 | } | ||
849 | 851 | ||
850 | l = *pos; | 852 | p = t_next(m, p, pos); |
851 | p = t_next(m, p, &l); | ||
852 | 853 | ||
853 | return p; | 854 | return p; |
854 | } | 855 | } |
@@ -859,21 +860,15 @@ static void t_stop(struct seq_file *m, void *p) | |||
859 | 860 | ||
860 | static int t_show(struct seq_file *m, void *v) | 861 | static int t_show(struct seq_file *m, void *v) |
861 | { | 862 | { |
862 | struct ftrace_iterator *iter = m->private; | ||
863 | struct dyn_ftrace *rec = v; | 863 | struct dyn_ftrace *rec = v; |
864 | char str[KSYM_SYMBOL_LEN]; | 864 | char str[KSYM_SYMBOL_LEN]; |
865 | int ret = 0; | ||
866 | 865 | ||
867 | if (!rec) | 866 | if (!rec) |
868 | return 0; | 867 | return 0; |
869 | 868 | ||
870 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); | 869 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); |
871 | 870 | ||
872 | ret = seq_printf(m, "%s\n", str); | 871 | seq_printf(m, "%s\n", str); |
873 | if (ret < 0) { | ||
874 | iter->pos--; | ||
875 | iter->idx--; | ||
876 | } | ||
877 | 872 | ||
878 | return 0; | 873 | return 0; |
879 | } | 874 | } |
@@ -899,7 +894,6 @@ ftrace_avail_open(struct inode *inode, struct file *file) | |||
899 | return -ENOMEM; | 894 | return -ENOMEM; |
900 | 895 | ||
901 | iter->pg = ftrace_pages_start; | 896 | iter->pg = ftrace_pages_start; |
902 | iter->pos = 0; | ||
903 | 897 | ||
904 | ret = seq_open(file, &show_ftrace_seq_ops); | 898 | ret = seq_open(file, &show_ftrace_seq_ops); |
905 | if (!ret) { | 899 | if (!ret) { |
@@ -986,7 +980,6 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable) | |||
986 | 980 | ||
987 | if (file->f_mode & FMODE_READ) { | 981 | if (file->f_mode & FMODE_READ) { |
988 | iter->pg = ftrace_pages_start; | 982 | iter->pg = ftrace_pages_start; |
989 | iter->pos = 0; | ||
990 | iter->flags = enable ? FTRACE_ITER_FILTER : | 983 | iter->flags = enable ? FTRACE_ITER_FILTER : |
991 | FTRACE_ITER_NOTRACE; | 984 | FTRACE_ITER_NOTRACE; |
992 | 985 | ||