aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-26 13:25:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-29 12:47:33 -0400
commitc6febdf258313a120acd1298dd1dd41442131a37 (patch)
treef85f8afe306d9ea8e10c3417f94e901b41b6074b /kernel
parentb86d0ba62decb830aed2fa525e7557857d3199f2 (diff)
tracing: Introduce remove_event_file_dir()
commit f6a84bdc75b5c11621dec58db73fe102cbaf40cc upstream. Preparation for the next patch. Extract the common code from remove_event_from_tracers() and __trace_remove_event_dirs() into the new helper, remove_event_file_dir(). The patch looks more complicated than it actually is, it also moves remove_subsystem() up to avoid the forward declaration. Link: http://lkml.kernel.org/r/20130726172547.GA3629@redhat.com Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_events.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 09782d623c93..422f99dfe699 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -407,11 +407,31 @@ static void put_system(struct ftrace_subsystem_dir *dir)
407 mutex_unlock(&event_mutex); 407 mutex_unlock(&event_mutex);
408} 408}
409 409
410static void remove_subsystem(struct ftrace_subsystem_dir *dir)
411{
412 if (!dir)
413 return;
414
415 if (!--dir->nr_events) {
416 debugfs_remove_recursive(dir->entry);
417 list_del(&dir->list);
418 __put_system_dir(dir);
419 }
420}
421
410static void *event_file_data(struct file *filp) 422static void *event_file_data(struct file *filp)
411{ 423{
412 return ACCESS_ONCE(file_inode(filp)->i_private); 424 return ACCESS_ONCE(file_inode(filp)->i_private);
413} 425}
414 426
427static void remove_event_file_dir(struct ftrace_event_file *file)
428{
429 list_del(&file->list);
430 debugfs_remove_recursive(file->dir);
431 remove_subsystem(file->system);
432 kmem_cache_free(file_cachep, file);
433}
434
415/* 435/*
416 * Open and update trace_array ref count. 436 * Open and update trace_array ref count.
417 * Must have the current trace_array passed to it. 437 * Must have the current trace_array passed to it.
@@ -1571,33 +1591,16 @@ event_create_dir(struct dentry *parent,
1571 return 0; 1591 return 0;
1572} 1592}
1573 1593
1574static void remove_subsystem(struct ftrace_subsystem_dir *dir)
1575{
1576 if (!dir)
1577 return;
1578
1579 if (!--dir->nr_events) {
1580 debugfs_remove_recursive(dir->entry);
1581 list_del(&dir->list);
1582 __put_system_dir(dir);
1583 }
1584}
1585
1586static void remove_event_from_tracers(struct ftrace_event_call *call) 1594static void remove_event_from_tracers(struct ftrace_event_call *call)
1587{ 1595{
1588 struct ftrace_event_file *file; 1596 struct ftrace_event_file *file;
1589 struct trace_array *tr; 1597 struct trace_array *tr;
1590 1598
1591 do_for_each_event_file_safe(tr, file) { 1599 do_for_each_event_file_safe(tr, file) {
1592
1593 if (file->event_call != call) 1600 if (file->event_call != call)
1594 continue; 1601 continue;
1595 1602
1596 list_del(&file->list); 1603 remove_event_file_dir(file);
1597 debugfs_remove_recursive(file->dir);
1598 remove_subsystem(file->system);
1599 kmem_cache_free(file_cachep, file);
1600
1601 /* 1604 /*
1602 * The do_for_each_event_file_safe() is 1605 * The do_for_each_event_file_safe() is
1603 * a double loop. After finding the call for this 1606 * a double loop. After finding the call for this
@@ -2330,12 +2333,8 @@ __trace_remove_event_dirs(struct trace_array *tr)
2330{ 2333{
2331 struct ftrace_event_file *file, *next; 2334 struct ftrace_event_file *file, *next;
2332 2335
2333 list_for_each_entry_safe(file, next, &tr->events, list) { 2336 list_for_each_entry_safe(file, next, &tr->events, list)
2334 list_del(&file->list); 2337 remove_event_file_dir(file);
2335 debugfs_remove_recursive(file->dir);
2336 remove_subsystem(file->system);
2337 kmem_cache_free(file_cachep, file);
2338 }
2339} 2338}
2340 2339
2341static void 2340static void