Re: [PATCH v1] ftrace: Make ftrace_graph_is_dead() static inline
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2022-03-24 22:33:56
Also in:
lkml
On Thu, 24 Mar 2022 11:01:45 +0100 Christophe Leroy [off-list ref] wrote:
quoted hunk ↗ jump to hunk
@@ -1006,7 +1006,20 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, extern int register_ftrace_graph(struct fgraph_ops *ops); extern void unregister_ftrace_graph(struct fgraph_ops *ops); -extern bool ftrace_graph_is_dead(void); +/** + * ftrace_graph_is_dead - returns true if ftrace_graph_stop() was called + * + * ftrace_graph_stop() is called when a severe error is detected in + * the function graph tracing. This function is called by the critical + * paths of function graph to keep those paths from doing any more harm. + */ +extern bool kill_ftrace_graph; + +static inline bool ftrace_graph_is_dead(void) +{ + return kill_ftrace_graph; +} + extern void ftrace_graph_stop(void);
The reason I did not expose that variable, is because I didn't want it to
be touched outside of the kernel/trace directory. Or the ftrace.c file for
that matter (although, I could put it in fgraph.c :-/)
What would be better, is to make it a static branch.
extern struct static_key fgraph_dead;
static inline bool ftrace_graph_is_dead(void)
{
if (static_key_false(&fgraph_dead))
return true;
return false;
}
That way we even get rid of the conditional branch.
Yeah, the fgraph_dead is still exposed for anyone to touch, but it still
requires a function to modify it, so I'm not as worried it will be touched
as easily.
-- Steve