Commit a485ea9e3ef3 ("tracing: Fix irqsoff and wakeup latency tracers when
using function graph") added fgraph_reserve_data()/fgraph_retrieve_data() to
the irqsoff tracer's function-graph hooks.

When func_prolog_dec() succeeded but those calls failed, the code returned
without undoing the prolog (no local_dec(&data->disabled)). While
func_prolog_dec() does not disable preemption, this left the tracer recursion
guard (data->disabled) incremented on this CPU, suppressing subsequent tracing
and leaving the tracer state inconsistent.

Balance the prolog on these failure paths in both entry and return hooks.

Fixes: a485ea9e3ef3 ("tracing: Fix irqsoff and wakeup latency tracers when 
using function graph")
Assisted-by: gpt-5-codex
Signed-off-by: Sasha Levin <[email protected]>
---
 kernel/trace/trace_irqsoff.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 5496758b6c760..39152ef3d2432 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -202,8 +202,10 @@ static int irqsoff_graph_entry(struct ftrace_graph_ent 
*trace,
                return 0;
 
        calltime = fgraph_reserve_data(gops->idx, sizeof(*calltime));
-       if (!calltime)
+       if (!calltime) {
+               local_dec(&data->disabled);
                return 0;
+       }
 
        *calltime = trace_clock_local();
 
@@ -233,8 +235,10 @@ static void irqsoff_graph_return(struct ftrace_graph_ret 
*trace,
 
        rettime = trace_clock_local();
        calltime = fgraph_retrieve_data(gops->idx, &size);
-       if (!calltime)
+       if (!calltime) {
+               local_dec(&data->disabled);
                return;
+       }
 
        trace_ctx = tracing_gen_ctx_flags(flags);
        __trace_graph_return(tr, trace, trace_ctx, *calltime, rettime);
-- 
2.51.0

Reply via email to