Skip to content

Commit dcc19d2

Browse files
committed
tracing/ftrace: Allow for instances to trigger their own stacktrace probes
Have the stacktrace function trigger probe trigger stack traces within the instance that they were added to in the set_ftrace_filter. ># cd /sys/kernel/debug/tracing ># mkdir instances/foo ># cd instances/foo ># echo schedule:stacktrace:1 > set_ftrace_filter ># cat trace # tracer: nop # # entries-in-buffer/entries-written: 1/1 #P:4 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | <idle>-0 [001] .N.2 202.585010: <stack trace> => => schedule => schedule_preempt_disabled => do_idle => cpu_startup_entry => start_secondary => verify_cpu Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 2290f2c commit dcc19d2

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎kernel/trace/trace_functions.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,23 @@ ftrace_traceoff(unsigned long ip, unsigned long parent_ip,
375375
*/
376376
#define STACK_SKIP 4
377377

378+
static __always_inline void trace_stack(struct trace_array *tr)
379+
{
380+
unsigned long flags;
381+
int pc;
382+
383+
local_save_flags(flags);
384+
pc = preempt_count();
385+
386+
__trace_stack(tr, flags, STACK_SKIP, pc);
387+
}
388+
378389
static void
379390
ftrace_stacktrace(unsigned long ip, unsigned long parent_ip,
380391
struct trace_array *tr, struct ftrace_probe_ops *ops,
381392
void *data)
382393
{
383-
trace_dump_stack(STACK_SKIP);
394+
trace_stack(tr);
384395
}
385396

386397
static void
@@ -398,7 +409,7 @@ ftrace_stacktrace_count(unsigned long ip, unsigned long parent_ip,
398409

399410
/* unlimited? */
400411
if (!mapper) {
401-
trace_dump_stack(STACK_SKIP);
412+
trace_stack(tr);
402413
return;
403414
}
404415

@@ -417,7 +428,7 @@ ftrace_stacktrace_count(unsigned long ip, unsigned long parent_ip,
417428
new_count = old_count - 1;
418429
new_count = cmpxchg(count, old_count, new_count);
419430
if (new_count == old_count)
420-
trace_dump_stack(STACK_SKIP);
431+
trace_stack(tr);
421432

422433
if (!tracing_is_on())
423434
return;

0 commit comments

Comments
 (0)