diff options
Diffstat (limited to 'kernel/trace/trace_stat.c')
-rw-r--r-- | kernel/trace/trace_stat.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c index c00643733f4c..aea321c82fa0 100644 --- a/kernel/trace/trace_stat.c +++ b/kernel/trace/trace_stat.c | |||
@@ -73,7 +73,7 @@ static struct rb_node *release_next(struct rb_node *node) | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | static void reset_stat_session(struct stat_session *session) | 76 | static void __reset_stat_session(struct stat_session *session) |
77 | { | 77 | { |
78 | struct rb_node *node = session->stat_root.rb_node; | 78 | struct rb_node *node = session->stat_root.rb_node; |
79 | 79 | ||
@@ -83,10 +83,17 @@ static void reset_stat_session(struct stat_session *session) | |||
83 | session->stat_root = RB_ROOT; | 83 | session->stat_root = RB_ROOT; |
84 | } | 84 | } |
85 | 85 | ||
86 | static void reset_stat_session(struct stat_session *session) | ||
87 | { | ||
88 | mutex_lock(&session->stat_mutex); | ||
89 | __reset_stat_session(session); | ||
90 | mutex_unlock(&session->stat_mutex); | ||
91 | } | ||
92 | |||
86 | static void destroy_session(struct stat_session *session) | 93 | static void destroy_session(struct stat_session *session) |
87 | { | 94 | { |
88 | debugfs_remove(session->file); | 95 | debugfs_remove(session->file); |
89 | reset_stat_session(session); | 96 | __reset_stat_session(session); |
90 | mutex_destroy(&session->stat_mutex); | 97 | mutex_destroy(&session->stat_mutex); |
91 | kfree(session); | 98 | kfree(session); |
92 | } | 99 | } |
@@ -150,7 +157,7 @@ static int stat_seq_init(struct stat_session *session) | |||
150 | int i; | 157 | int i; |
151 | 158 | ||
152 | mutex_lock(&session->stat_mutex); | 159 | mutex_lock(&session->stat_mutex); |
153 | reset_stat_session(session); | 160 | __reset_stat_session(session); |
154 | 161 | ||
155 | if (!ts->stat_cmp) | 162 | if (!ts->stat_cmp) |
156 | ts->stat_cmp = dummy_cmp; | 163 | ts->stat_cmp = dummy_cmp; |
@@ -183,7 +190,7 @@ exit: | |||
183 | return ret; | 190 | return ret; |
184 | 191 | ||
185 | exit_free_rbtree: | 192 | exit_free_rbtree: |
186 | reset_stat_session(session); | 193 | __reset_stat_session(session); |
187 | mutex_unlock(&session->stat_mutex); | 194 | mutex_unlock(&session->stat_mutex); |
188 | return ret; | 195 | return ret; |
189 | } | 196 | } |
@@ -199,17 +206,13 @@ static void *stat_seq_start(struct seq_file *s, loff_t *pos) | |||
199 | mutex_lock(&session->stat_mutex); | 206 | mutex_lock(&session->stat_mutex); |
200 | 207 | ||
201 | /* If we are in the beginning of the file, print the headers */ | 208 | /* If we are in the beginning of the file, print the headers */ |
202 | if (!*pos && session->ts->stat_headers) { | 209 | if (!*pos && session->ts->stat_headers) |
203 | (*pos)++; | ||
204 | return SEQ_START_TOKEN; | 210 | return SEQ_START_TOKEN; |
205 | } | ||
206 | 211 | ||
207 | node = rb_first(&session->stat_root); | 212 | node = rb_first(&session->stat_root); |
208 | for (i = 0; node && i < *pos; i++) | 213 | for (i = 0; node && i < *pos; i++) |
209 | node = rb_next(node); | 214 | node = rb_next(node); |
210 | 215 | ||
211 | (*pos)++; | ||
212 | |||
213 | return node; | 216 | return node; |
214 | } | 217 | } |
215 | 218 | ||
@@ -254,16 +257,21 @@ static const struct seq_operations trace_stat_seq_ops = { | |||
254 | static int tracing_stat_open(struct inode *inode, struct file *file) | 257 | static int tracing_stat_open(struct inode *inode, struct file *file) |
255 | { | 258 | { |
256 | int ret; | 259 | int ret; |
257 | 260 | struct seq_file *m; | |
258 | struct stat_session *session = inode->i_private; | 261 | struct stat_session *session = inode->i_private; |
259 | 262 | ||
263 | ret = stat_seq_init(session); | ||
264 | if (ret) | ||
265 | return ret; | ||
266 | |||
260 | ret = seq_open(file, &trace_stat_seq_ops); | 267 | ret = seq_open(file, &trace_stat_seq_ops); |
261 | if (!ret) { | 268 | if (ret) { |
262 | struct seq_file *m = file->private_data; | 269 | reset_stat_session(session); |
263 | m->private = session; | 270 | return ret; |
264 | ret = stat_seq_init(session); | ||
265 | } | 271 | } |
266 | 272 | ||
273 | m = file->private_data; | ||
274 | m->private = session; | ||
267 | return ret; | 275 | return ret; |
268 | } | 276 | } |
269 | 277 | ||
@@ -274,11 +282,9 @@ static int tracing_stat_release(struct inode *i, struct file *f) | |||
274 | { | 282 | { |
275 | struct stat_session *session = i->i_private; | 283 | struct stat_session *session = i->i_private; |
276 | 284 | ||
277 | mutex_lock(&session->stat_mutex); | ||
278 | reset_stat_session(session); | 285 | reset_stat_session(session); |
279 | mutex_unlock(&session->stat_mutex); | ||
280 | 286 | ||
281 | return 0; | 287 | return seq_release(i, f); |
282 | } | 288 | } |
283 | 289 | ||
284 | static const struct file_operations tracing_stat_fops = { | 290 | static const struct file_operations tracing_stat_fops = { |