Skip to content

Commit

Permalink
ftrace: Fix ftrace_trace_task return value
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
josefbacik authored and rostedt committed Aug 3, 2020
1 parent 1c39d76 commit c58b6b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 0 additions & 3 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ static inline void ftrace_ops_init(struct ftrace_ops *ops)
#endif
}

#define FTRACE_PID_IGNORE -1
#define FTRACE_PID_TRACE -2

static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *op, struct pt_regs *regs)
{
Expand Down
7 changes: 6 additions & 1 deletion kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,10 @@ print_graph_function_flags(struct trace_iterator *iter, u32 flags)
extern struct list_head ftrace_pids;

#ifdef CONFIG_FUNCTION_TRACER

#define FTRACE_PID_IGNORE -1
#define FTRACE_PID_TRACE -2

struct ftrace_func_command {
struct list_head list;
char *name;
Expand All @@ -1114,7 +1118,8 @@ struct ftrace_func_command {
extern bool ftrace_filter_param __initdata;
static inline int ftrace_trace_task(struct trace_array *tr)
{
return !this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);
return this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid) !=
FTRACE_PID_IGNORE;
}
extern int ftrace_is_dead(void);
int ftrace_create_function_files(struct trace_array *tr,
Expand Down

0 comments on commit c58b6b0

Please sign in to comment.