From: Steven Rostedt <rostedt@xxxxxxxxxxx> commit 8eb4b09e0bbd30981305643229fe7640ad41b667 upstream. Check if a function is already in the manager ops of a subops. A manager ops contains multiple subops, and if two or more subops are tracing the same function, the manager ops only needs a single entry in its hash. Cc: stable@xxxxxxxxxxxxxxx Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Sven Schnelle <svens@xxxxxxxxxxxxx> Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx> Cc: Alexander Gordeev <agordeev@xxxxxxxxxxxxx> Link: https://lore.kernel.org/20250220202055.226762894@xxxxxxxxxxx Fixes: 4f554e955614f ("ftrace: Add ftrace_set_filter_ips function") Tested-by: Heiko Carstens <hca@xxxxxxxxxxxxx> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/trace/ftrace.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5770,6 +5770,9 @@ __ftrace_match_addr(struct ftrace_hash * return -ENOENT; free_hash_entry(hash, entry); return 0; + } else if (__ftrace_lookup_ip(hash, ip) != NULL) { + /* Already exists */ + return 0; } entry = add_hash_entry(hash, ip); Patches currently in stable-queue which might be from rostedt@xxxxxxxxxxx are queue-6.13/tracing-switch-trace.c-code-over-to-use-guard.patch queue-6.13/tracing-have-the-error-of-__tracing_resize_ring_buff.patch queue-6.13/ftrace-correct-preemption-accounting-for-function-tracing.patch queue-6.13/ftrace-do-not-add-duplicate-entries-in-subops-manager-ops.patch queue-6.13/ftrace-fix-accounting-of-adding-subops-to-a-manager-ops.patch