* [PATCH] ftrace: fix ftrace_trace_task return value
@ 2020-07-25 0:50 Josef Bacik
2020-07-27 15:42 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2020-07-25 0:50 UTC (permalink / raw)
To: kernel-team, linux-kernel, rostedt, mingo
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.
Fixes: 717e3f5ebc82 ("ftrace: Make function trace pid filtering a bit more exact")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel/trace/ftrace.c | 3 ---
kernel/trace/trace.h | 7 ++++++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1903b80db6eb..7d879fae3777 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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)
{
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 13db4000af3f..1531ec565cb5 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -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;
@@ -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,
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ftrace: fix ftrace_trace_task return value
2020-07-25 0:50 [PATCH] ftrace: fix ftrace_trace_task return value Josef Bacik
@ 2020-07-27 15:42 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2020-07-27 15:42 UTC (permalink / raw)
To: Josef Bacik; +Cc: kernel-team, linux-kernel, mingo
On Fri, 24 Jul 2020 20:50:48 -0400
Josef Bacik <josef@toxicpanda.com> wrote:
> 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.
>
I just ran into this myself! And was about to go look at why function
graph pid filtering wasn't working. Thanks for the patch! I'll start
testing it this week.
-- Steve
> Fixes: 717e3f5ebc82 ("ftrace: Make function trace pid filtering a bit more exact")
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> kernel/trace/ftrace.c | 3 ---
> kernel/trace/trace.h | 7 ++++++-
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 1903b80db6eb..7d879fae3777 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -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)
> {
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 13db4000af3f..1531ec565cb5 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -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;
> @@ -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,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-27 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-25 0:50 [PATCH] ftrace: fix ftrace_trace_task return value Josef Bacik
2020-07-27 15:42 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).