From 4617721c502b2ddaa4e324e86da4997edf738fa5 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 2 Sep 2026 09:55:01 -0400 Subject: ftrace: Synchronize the initialization of ftrace_ops There's some internal state that ftrace_ops needs to have set, but since it can be declared outside of the ftrace.c code, it calls ftrace_ops_init() on the ops in every global function. The issue is that if two tasks call it on the same ops at the same time it is possible to have the initialization of one corrupt the initialization of the other call. Create a ops_mutex to use to synchronize every initialization of the ftrace_ops. The mutex is taken within checking the ftrace_ops flag that states it was initializied but the flag is checked again after the mutex has been taken. Checking first outside the mutex allows it to shortcut having to take the mutex. But then the check needs to be done again after the mute is taken in case of races. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260902095501.6b59af20@gandalf.local.home Fixes: f04f24fb7e48d ("ftrace, kprobes: Fix a deadlock on ftrace_regex_lock") Reported-by: sashiko-bot@kernel.org Close: https://lore.kernel.org/all/20260829025528.49A831F000E9@smtp.kernel.org/ Signed-off-by: Steven Rostedt --- tools/perf/util/srcline.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tools/perf/util/srcline.h (limited to 'tools/perf/util/srcline.h') diff --git a/tools/perf/util/srcline.h b/tools/perf/util/srcline.h new file mode 100644 index 000000000..1018cbc88 --- /dev/null +++ b/tools/perf/util/srcline.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef PERF_SRCLINE_H +#define PERF_SRCLINE_H + +#include +#include +#include + +struct dso; +struct symbol; + +extern bool srcline_full_filename; +char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, + bool show_sym, bool show_addr, u64 ip); +char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym, + bool show_sym, bool show_addr, bool unwind_inlines, + u64 ip); +void zfree_srcline(char **srcline); +char *get_srcline_split(struct dso *dso, u64 addr, unsigned *line); + +/* insert the srcline into the DSO, which will take ownership */ +void srcline__tree_insert(struct rb_root_cached *tree, u64 addr, char *srcline); +/* find previously inserted srcline */ +char *srcline__tree_find(struct rb_root_cached *tree, u64 addr); +/* delete all srclines within the tree */ +void srcline__tree_delete(struct rb_root_cached *tree); + +extern char *srcline__unknown; +#define SRCLINE_UNKNOWN srcline__unknown + +#define MAX_INLINE_NEST 1024 + +struct inline_list { + struct symbol *symbol; + char *srcline; + struct list_head list; +}; + +struct inline_node { + u64 addr; + struct list_head val; + struct rb_node rb_node; +}; + +/* parse inlined frames for the given address */ +struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr, + struct symbol *sym); +/* free resources associated to the inline node list */ +void inline_node__delete(struct inline_node *node); +void inline_node__clear_frames(struct inline_node *node); + +/* insert the inline node list into the DSO, which will take ownership */ +void inlines__tree_insert(struct rb_root_cached *tree, + struct inline_node *inlines); +/* find previously inserted inline node list */ +struct inline_node *inlines__tree_find(struct rb_root_cached *tree, u64 addr); +/* delete all nodes within the tree of inline_node s */ +void inlines__tree_delete(struct rb_root_cached *tree); + +int inline_list__append(struct symbol *symbol, char *srcline, struct inline_node *node); +int inline_list__append_tail(struct symbol *symbol, char *srcline, struct inline_node *node); +char *srcline_from_fileline(const char *file, unsigned int line); +struct symbol *new_inline_sym(struct dso *dso, + struct symbol *base_sym, + const char *funcname); + +int addr2line_configure(const char *var, const char *value, void *cb); + +#endif /* PERF_SRCLINE_H */ -- cgit v1.3.1