tracing/ftrace: Enable snapshot function trigger to work with instances

Modify the snapshot probe trigger to work with instances. This way the
snapshot function trigger will only affect the instance that it is added to
in the set_ftrace_filter file.
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent d2afd57a
...@@ -894,23 +894,8 @@ int __trace_bputs(unsigned long ip, const char *str) ...@@ -894,23 +894,8 @@ int __trace_bputs(unsigned long ip, const char *str)
EXPORT_SYMBOL_GPL(__trace_bputs); EXPORT_SYMBOL_GPL(__trace_bputs);
#ifdef CONFIG_TRACER_SNAPSHOT #ifdef CONFIG_TRACER_SNAPSHOT
/** static void tracing_snapshot_instance(struct trace_array *tr)
* trace_snapshot - take a snapshot of the current buffer.
*
* This causes a swap between the snapshot buffer and the current live
* tracing buffer. You can use this to take snapshots of the live
* trace when some condition is triggered, but continue to trace.
*
* Note, make sure to allocate the snapshot with either
* a tracing_snapshot_alloc(), or by doing it manually
* with: echo 1 > /sys/kernel/debug/tracing/snapshot
*
* If the snapshot buffer is not allocated, it will stop tracing.
* Basically making a permanent snapshot.
*/
void tracing_snapshot(void)
{ {
struct trace_array *tr = &global_trace;
struct tracer *tracer = tr->current_trace; struct tracer *tracer = tr->current_trace;
unsigned long flags; unsigned long flags;
...@@ -938,6 +923,27 @@ void tracing_snapshot(void) ...@@ -938,6 +923,27 @@ void tracing_snapshot(void)
update_max_tr(tr, current, smp_processor_id()); update_max_tr(tr, current, smp_processor_id());
local_irq_restore(flags); local_irq_restore(flags);
} }
/**
* trace_snapshot - take a snapshot of the current buffer.
*
* This causes a swap between the snapshot buffer and the current live
* tracing buffer. You can use this to take snapshots of the live
* trace when some condition is triggered, but continue to trace.
*
* Note, make sure to allocate the snapshot with either
* a tracing_snapshot_alloc(), or by doing it manually
* with: echo 1 > /sys/kernel/debug/tracing/snapshot
*
* If the snapshot buffer is not allocated, it will stop tracing.
* Basically making a permanent snapshot.
*/
void tracing_snapshot(void)
{
struct trace_array *tr = &global_trace;
tracing_snapshot_instance(tr);
}
EXPORT_SYMBOL_GPL(tracing_snapshot); EXPORT_SYMBOL_GPL(tracing_snapshot);
static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf, static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf,
...@@ -6739,7 +6745,7 @@ ftrace_snapshot(unsigned long ip, unsigned long parent_ip, ...@@ -6739,7 +6745,7 @@ ftrace_snapshot(unsigned long ip, unsigned long parent_ip,
struct trace_array *tr, struct ftrace_probe_ops *ops, struct trace_array *tr, struct ftrace_probe_ops *ops,
void *data) void *data)
{ {
tracing_snapshot(); tracing_snapshot_instance(tr);
} }
static void static void
...@@ -6761,7 +6767,7 @@ ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip, ...@@ -6761,7 +6767,7 @@ ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip,
(*count)--; (*count)--;
} }
tracing_snapshot(); tracing_snapshot_instance(tr);
} }
static int static int
...@@ -6868,7 +6874,7 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash, ...@@ -6868,7 +6874,7 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash,
ret = register_ftrace_function_probe(glob, tr, ops, count); ret = register_ftrace_function_probe(glob, tr, ops, count);
if (ret >= 0) if (ret >= 0)
alloc_snapshot(&global_trace); alloc_snapshot(tr);
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment