History

ftrace: Allow for function tracing instance to filter functions

Create a "set_ftrace_filter" and "set_ftrace_notrace" files in the instance directories to let users filter of functions to trace for the given instance.

Steven Rostedt (Red Hat) committed 12 years ago

Commit 591dffd1 parent e3b3e2e5 files · +96 −14Browse files

Showing the changes to kernel/trace/trace_functions.c (1 of 5 files). Show all

Unified · Split

kernel/trace/trace_functions.c+32−8
@@ -52,10 +52,34 @@ static int allocate_ftrace_ops(struct trace_array *tr) · 51 unmodified lines
5252 return 0;
5353 }
5454
55+
56+int ftrace_create_function_files(struct trace_array *tr,
57+ struct dentry *parent)
58+{
59+ int ret;
60+
61+ /* The top level array uses the "global_ops". */
62+ if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL)) {
63+ ret = allocate_ftrace_ops(tr);
64+ if (ret)
65+ return ret;
66+ }
67+
68+ ftrace_create_filter_files(tr->ops, parent);
69+
70+ return 0;
71+}
72+
73+void ftrace_destroy_function_files(struct trace_array *tr)
74+{
75+ ftrace_destroy_filter_files(tr->ops);
76+ kfree(tr->ops);
77+ tr->ops = NULL;
78+}
79+
5580 static int function_trace_init(struct trace_array *tr)
5681 {
5782 struct ftrace_ops *ops;
58− int ret;
5983
6084 if (tr->flags & TRACE_ARRAY_FL_GLOBAL) {
6185 /* There's only one global tr */
@@ -69,10 +93,13 @@ static int function_trace_init(struct trace_array *tr) · 7 unmodified lines
6993 else
7094 ops = &trace_ops;
7195 tr->ops = ops;
72− } else {
73− ret = allocate_ftrace_ops(tr);
74− if (ret)
75− return ret;
96+ } else if (!tr->ops) {
97+ /*
98+ * Instance trace_arrays get their ops allocated
99+ * at instance creation. Unless it failed
100+ * the allocation.
101+ */
102+ return -ENOMEM;
76103 }
77104
78105 tr->trace_buffer.cpu = get_cpu();
@@ -87,9 +114,6 @@ static void function_trace_reset(struct trace_array *tr) · 8 unmodified lines
87114 {
88115 tracing_stop_function_trace(tr);
89116 tracing_stop_cmdline_record();
90− if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL))
91− kfree(tr->ops);
92− tr->ops = NULL;
93117 }
94118
95119 static void function_trace_start(struct trace_array *tr)