Skip to content

Commit d2d45c7

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Have stack_tracer use a separate list of functions
The stack_tracer is used to look at every function and check if the current stack is bigger than the last recorded max stack size. When a new max is found, then it saves that stack off. Currently the stack tracer is limited by the global_ops of the function tracer. As the stack tracer has nothing to do with the ftrace function tracer, except that it uses it as its internal engine, the stack tracer should have its own list. A new file is added to the tracing debugfs directory called: stack_trace_filter that can be used to select which functions you want to check the stack on. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 69a3083 commit d2d45c7

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

kernel/trace/trace_stack.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
133133
static struct ftrace_ops trace_ops __read_mostly =
134134
{
135135
.func = stack_trace_call,
136-
.flags = FTRACE_OPS_FL_GLOBAL,
137136
};
138137

139138
static ssize_t
@@ -311,6 +310,21 @@ static const struct file_operations stack_trace_fops = {
311310
.release = seq_release,
312311
};
313312

313+
static int
314+
stack_trace_filter_open(struct inode *inode, struct file *file)
315+
{
316+
return ftrace_regex_open(&trace_ops, FTRACE_ITER_FILTER,
317+
inode, file);
318+
}
319+
320+
static const struct file_operations stack_trace_filter_fops = {
321+
.open = stack_trace_filter_open,
322+
.read = seq_read,
323+
.write = ftrace_filter_write,
324+
.llseek = ftrace_regex_lseek,
325+
.release = ftrace_regex_release,
326+
};
327+
314328
int
315329
stack_trace_sysctl(struct ctl_table *table, int write,
316330
void __user *buffer, size_t *lenp,
@@ -358,6 +372,9 @@ static __init int stack_trace_init(void)
358372
trace_create_file("stack_trace", 0444, d_tracer,
359373
NULL, &stack_trace_fops);
360374

375+
trace_create_file("stack_trace_filter", 0444, d_tracer,
376+
NULL, &stack_trace_filter_fops);
377+
361378
if (stack_tracer_enabled)
362379
register_ftrace_function(&trace_ops);
363380

0 commit comments

Comments
 (0)