summaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorTingwei Zhang <tingwei@codeaurora.org>2020-10-05 10:13:13 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-05 12:43:53 +0200
commit8438f5211479e4b8433f641634362264bc3bbd9e (patch)
treeff1d0424ebf55860846a662149d3a48189ab2a73 /kernel/trace
parent7b9749bd830848bca9179b0a16251ca3c36e82e6 (diff)
downloadlinux-8438f5211479e4b8433f641634362264bc3bbd9e.tar.bz2
tracing: Add flag to control different traces
More traces like event trace or trace marker will be supported. Add flag for difference traces, so that they can be controlled separately. Move current function trace to it's own flag instead of global ftrace enable flag. Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Reviewed-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Tingwei Zhang <tingwei@codeaurora.org> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Link: https://lore.kernel.org/r/20201005071319.78508-3-alexander.shishkin@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f40d850ebabc..3ca121ad8728 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2744,33 +2744,37 @@ trace_buffer_unlock_commit_nostack(struct trace_buffer *buffer,
static void
trace_process_export(struct trace_export *export,
- struct ring_buffer_event *event)
+ struct ring_buffer_event *event, int flag)
{
struct trace_entry *entry;
unsigned int size = 0;
- entry = ring_buffer_event_data(event);
- size = ring_buffer_event_length(event);
- export->write(export, entry, size);
+ if (export->flags & flag) {
+ entry = ring_buffer_event_data(event);
+ size = ring_buffer_event_length(event);
+ export->write(export, entry, size);
+ }
}
static DEFINE_MUTEX(ftrace_export_lock);
static struct trace_export __rcu *ftrace_exports_list __read_mostly;
-static DEFINE_STATIC_KEY_FALSE(ftrace_exports_enabled);
+static DEFINE_STATIC_KEY_FALSE(trace_function_exports_enabled);
-static inline void ftrace_exports_enable(void)
+static inline void ftrace_exports_enable(struct trace_export *export)
{
- static_branch_enable(&ftrace_exports_enabled);
+ if (export->flags & TRACE_EXPORT_FUNCTION)
+ static_branch_inc(&trace_function_exports_enabled);
}
-static inline void ftrace_exports_disable(void)
+static inline void ftrace_exports_disable(struct trace_export *export)
{
- static_branch_disable(&ftrace_exports_enabled);
+ if (export->flags & TRACE_EXPORT_FUNCTION)
+ static_branch_dec(&trace_function_exports_enabled);
}
-static void ftrace_exports(struct ring_buffer_event *event)
+static void ftrace_exports(struct ring_buffer_event *event, int flag)
{
struct trace_export *export;
@@ -2778,7 +2782,7 @@ static void ftrace_exports(struct ring_buffer_event *event)
export = rcu_dereference_raw_check(ftrace_exports_list);
while (export) {
- trace_process_export(export, event);
+ trace_process_export(export, event, flag);
export = rcu_dereference_raw_check(export->next);
}
@@ -2818,8 +2822,7 @@ rm_trace_export(struct trace_export **list, struct trace_export *export)
static inline void
add_ftrace_export(struct trace_export **list, struct trace_export *export)
{
- if (*list == NULL)
- ftrace_exports_enable();
+ ftrace_exports_enable(export);
add_trace_export(list, export);
}
@@ -2830,8 +2833,7 @@ rm_ftrace_export(struct trace_export **list, struct trace_export *export)
int ret;
ret = rm_trace_export(list, export);
- if (*list == NULL)
- ftrace_exports_disable();
+ ftrace_exports_disable(export);
return ret;
}
@@ -2884,8 +2886,8 @@ trace_function(struct trace_array *tr,
entry->parent_ip = parent_ip;
if (!call_filter_check_discard(call, entry, buffer, event)) {
- if (static_branch_unlikely(&ftrace_exports_enabled))
- ftrace_exports(event);
+ if (static_branch_unlikely(&trace_function_exports_enabled))
+ ftrace_exports(event, TRACE_EXPORT_FUNCTION);
__buffer_unlock_commit(buffer, event);
}
}