Skip to content

Commit c58b6b0

Browse files
josefbacikrostedt
authored andcommitted
ftrace: Fix ftrace_trace_task return value
I was attempting to use pid filtering with function_graph, but it wasn't allowing anything to make it through. Turns out ftrace_trace_task returns false if ftrace_ignore_pid is not-empty, which isn't correct anymore. We're now setting it to FTRACE_PID_IGNORE if we need to ignore that pid, otherwise it's set to the pid (which is weird considering the name) or to FTRACE_PID_TRACE. Fix the check to check for != FTRACE_PID_IGNORE. With this we can now use function_graph with pid filtering. Link: https://lkml.kernel.org/r/[email protected] Fixes: 717e3f5 ("ftrace: Make function trace pid filtering a bit more exact") Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 1c39d76 commit c58b6b0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

kernel/trace/ftrace.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ static inline void ftrace_ops_init(struct ftrace_ops *ops)
139139
#endif
140140
}
141141

142-
#define FTRACE_PID_IGNORE -1
143-
#define FTRACE_PID_TRACE -2
144-
145142
static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
146143
struct ftrace_ops *op, struct pt_regs *regs)
147144
{

kernel/trace/trace.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,10 @@ print_graph_function_flags(struct trace_iterator *iter, u32 flags)
11031103
extern struct list_head ftrace_pids;
11041104

11051105
#ifdef CONFIG_FUNCTION_TRACER
1106+
1107+
#define FTRACE_PID_IGNORE -1
1108+
#define FTRACE_PID_TRACE -2
1109+
11061110
struct ftrace_func_command {
11071111
struct list_head list;
11081112
char *name;
@@ -1114,7 +1118,8 @@ struct ftrace_func_command {
11141118
extern bool ftrace_filter_param __initdata;
11151119
static inline int ftrace_trace_task(struct trace_array *tr)
11161120
{
1117-
return !this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);
1121+
return this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid) !=
1122+
FTRACE_PID_IGNORE;
11181123
}
11191124
extern int ftrace_is_dead(void);
11201125
int ftrace_create_function_files(struct trace_array *tr,

0 commit comments

Comments
 (0)