diff options
Diffstat (limited to 'kernel/trace/trace_events.c')
| -rw-r--r-- | kernel/trace/trace_events.c | 98 |
1 files changed, 45 insertions, 53 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 7d854290bf81..898f868833f2 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
| @@ -826,59 +826,33 @@ enum { | |||
| 826 | static void *f_next(struct seq_file *m, void *v, loff_t *pos) | 826 | static void *f_next(struct seq_file *m, void *v, loff_t *pos) |
| 827 | { | 827 | { |
| 828 | struct ftrace_event_call *call = m->private; | 828 | struct ftrace_event_call *call = m->private; |
| 829 | struct ftrace_event_field *field; | ||
| 830 | struct list_head *common_head = &ftrace_common_fields; | 829 | struct list_head *common_head = &ftrace_common_fields; |
| 831 | struct list_head *head = trace_get_fields(call); | 830 | struct list_head *head = trace_get_fields(call); |
| 831 | struct list_head *node = v; | ||
| 832 | 832 | ||
| 833 | (*pos)++; | 833 | (*pos)++; |
| 834 | 834 | ||
| 835 | switch ((unsigned long)v) { | 835 | switch ((unsigned long)v) { |
| 836 | case FORMAT_HEADER: | 836 | case FORMAT_HEADER: |
| 837 | if (unlikely(list_empty(common_head))) | 837 | node = common_head; |
| 838 | return NULL; | 838 | break; |
| 839 | |||
| 840 | field = list_entry(common_head->prev, | ||
| 841 | struct ftrace_event_field, link); | ||
| 842 | return field; | ||
| 843 | 839 | ||
| 844 | case FORMAT_FIELD_SEPERATOR: | 840 | case FORMAT_FIELD_SEPERATOR: |
| 845 | if (unlikely(list_empty(head))) | 841 | node = head; |
| 846 | return NULL; | 842 | break; |
| 847 | |||
| 848 | field = list_entry(head->prev, struct ftrace_event_field, link); | ||
| 849 | return field; | ||
| 850 | 843 | ||
| 851 | case FORMAT_PRINTFMT: | 844 | case FORMAT_PRINTFMT: |
| 852 | /* all done */ | 845 | /* all done */ |
| 853 | return NULL; | 846 | return NULL; |
| 854 | } | 847 | } |
| 855 | 848 | ||
| 856 | field = v; | 849 | node = node->prev; |
| 857 | if (field->link.prev == common_head) | 850 | if (node == common_head) |
| 858 | return (void *)FORMAT_FIELD_SEPERATOR; | 851 | return (void *)FORMAT_FIELD_SEPERATOR; |
| 859 | else if (field->link.prev == head) | 852 | else if (node == head) |
| 860 | return (void *)FORMAT_PRINTFMT; | 853 | return (void *)FORMAT_PRINTFMT; |
| 861 | 854 | else | |
| 862 | field = list_entry(field->link.prev, struct ftrace_event_field, link); | 855 | return node; |
| 863 | |||
| 864 | return field; | ||
| 865 | } | ||
| 866 | |||
| 867 | static void *f_start(struct seq_file *m, loff_t *pos) | ||
| 868 | { | ||
| 869 | loff_t l = 0; | ||
| 870 | void *p; | ||
| 871 | |||
| 872 | /* Start by showing the header */ | ||
| 873 | if (!*pos) | ||
| 874 | return (void *)FORMAT_HEADER; | ||
| 875 | |||
| 876 | p = (void *)FORMAT_HEADER; | ||
| 877 | do { | ||
| 878 | p = f_next(m, p, &l); | ||
| 879 | } while (p && l < *pos); | ||
| 880 | |||
| 881 | return p; | ||
| 882 | } | 856 | } |
| 883 | 857 | ||
| 884 | static int f_show(struct seq_file *m, void *v) | 858 | static int f_show(struct seq_file *m, void *v) |
| @@ -904,8 +878,7 @@ static int f_show(struct seq_file *m, void *v) | |||
| 904 | return 0; | 878 | return 0; |
| 905 | } | 879 | } |
| 906 | 880 | ||
| 907 | field = v; | 881 | field = list_entry(v, struct ftrace_event_field, link); |
| 908 | |||
| 909 | /* | 882 | /* |
| 910 | * Smartly shows the array type(except dynamic array). | 883 | * Smartly shows the array type(except dynamic array). |
| 911 | * Normal: | 884 | * Normal: |
| @@ -932,6 +905,17 @@ static int f_show(struct seq_file *m, void *v) | |||
| 932 | return 0; | 905 | return 0; |
| 933 | } | 906 | } |
| 934 | 907 | ||
| 908 | static void *f_start(struct seq_file *m, loff_t *pos) | ||
| 909 | { | ||
| 910 | void *p = (void *)FORMAT_HEADER; | ||
| 911 | loff_t l = 0; | ||
| 912 | |||
| 913 | while (l < *pos && p) | ||
| 914 | p = f_next(m, p, &l); | ||
| 915 | |||
| 916 | return p; | ||
| 917 | } | ||
| 918 | |||
| 935 | static void f_stop(struct seq_file *m, void *p) | 919 | static void f_stop(struct seq_file *m, void *p) |
| 936 | { | 920 | { |
| 937 | } | 921 | } |
| @@ -963,23 +947,14 @@ static ssize_t | |||
| 963 | event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) | 947 | event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) |
| 964 | { | 948 | { |
| 965 | struct ftrace_event_call *call = filp->private_data; | 949 | struct ftrace_event_call *call = filp->private_data; |
| 966 | struct trace_seq *s; | 950 | char buf[32]; |
| 967 | int r; | 951 | int len; |
| 968 | 952 | ||
| 969 | if (*ppos) | 953 | if (*ppos) |
| 970 | return 0; | 954 | return 0; |
| 971 | 955 | ||
| 972 | s = kmalloc(sizeof(*s), GFP_KERNEL); | 956 | len = sprintf(buf, "%d\n", call->event.type); |
| 973 | if (!s) | 957 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, len); |
| 974 | return -ENOMEM; | ||
| 975 | |||
| 976 | trace_seq_init(s); | ||
| 977 | trace_seq_printf(s, "%d\n", call->event.type); | ||
| 978 | |||
| 979 | r = simple_read_from_buffer(ubuf, cnt, ppos, | ||
| 980 | s->buffer, s->len); | ||
| 981 | kfree(s); | ||
| 982 | return r; | ||
| 983 | } | 958 | } |
| 984 | 959 | ||
| 985 | static ssize_t | 960 | static ssize_t |
| @@ -1218,6 +1193,7 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) | |||
| 1218 | 1193 | ||
| 1219 | static int ftrace_event_avail_open(struct inode *inode, struct file *file); | 1194 | static int ftrace_event_avail_open(struct inode *inode, struct file *file); |
| 1220 | static int ftrace_event_set_open(struct inode *inode, struct file *file); | 1195 | static int ftrace_event_set_open(struct inode *inode, struct file *file); |
| 1196 | static int ftrace_event_release(struct inode *inode, struct file *file); | ||
| 1221 | 1197 | ||
| 1222 | static const struct seq_operations show_event_seq_ops = { | 1198 | static const struct seq_operations show_event_seq_ops = { |
| 1223 | .start = t_start, | 1199 | .start = t_start, |
| @@ -1245,7 +1221,7 @@ static const struct file_operations ftrace_set_event_fops = { | |||
| 1245 | .read = seq_read, | 1221 | .read = seq_read, |
| 1246 | .write = ftrace_event_write, | 1222 | .write = ftrace_event_write, |
| 1247 | .llseek = seq_lseek, | 1223 | .llseek = seq_lseek, |
| 1248 | .release = seq_release, | 1224 | .release = ftrace_event_release, |
| 1249 | }; | 1225 | }; |
| 1250 | 1226 | ||
| 1251 | static const struct file_operations ftrace_enable_fops = { | 1227 | static const struct file_operations ftrace_enable_fops = { |
| @@ -1323,6 +1299,15 @@ ftrace_event_open(struct inode *inode, struct file *file, | |||
| 1323 | return ret; | 1299 | return ret; |
| 1324 | } | 1300 | } |
| 1325 | 1301 | ||
| 1302 | static int ftrace_event_release(struct inode *inode, struct file *file) | ||
| 1303 | { | ||
| 1304 | struct trace_array *tr = inode->i_private; | ||
| 1305 | |||
| 1306 | trace_array_put(tr); | ||
| 1307 | |||
| 1308 | return seq_release(inode, file); | ||
| 1309 | } | ||
| 1310 | |||
| 1326 | static int | 1311 | static int |
| 1327 | ftrace_event_avail_open(struct inode *inode, struct file *file) | 1312 | ftrace_event_avail_open(struct inode *inode, struct file *file) |
| 1328 | { | 1313 | { |
| @@ -1336,12 +1321,19 @@ ftrace_event_set_open(struct inode *inode, struct file *file) | |||
| 1336 | { | 1321 | { |
| 1337 | const struct seq_operations *seq_ops = &show_set_event_seq_ops; | 1322 | const struct seq_operations *seq_ops = &show_set_event_seq_ops; |
| 1338 | struct trace_array *tr = inode->i_private; | 1323 | struct trace_array *tr = inode->i_private; |
| 1324 | int ret; | ||
| 1325 | |||
| 1326 | if (trace_array_get(tr) < 0) | ||
| 1327 | return -ENODEV; | ||
| 1339 | 1328 | ||
| 1340 | if ((file->f_mode & FMODE_WRITE) && | 1329 | if ((file->f_mode & FMODE_WRITE) && |
| 1341 | (file->f_flags & O_TRUNC)) | 1330 | (file->f_flags & O_TRUNC)) |
| 1342 | ftrace_clear_events(tr); | 1331 | ftrace_clear_events(tr); |
| 1343 | 1332 | ||
| 1344 | return ftrace_event_open(inode, file, seq_ops); | 1333 | ret = ftrace_event_open(inode, file, seq_ops); |
| 1334 | if (ret < 0) | ||
| 1335 | trace_array_put(tr); | ||
| 1336 | return ret; | ||
| 1345 | } | 1337 | } |
| 1346 | 1338 | ||
| 1347 | static struct event_subsystem * | 1339 | static struct event_subsystem * |
