Skip to content

Commit c834a97

Browse files
committed
tracing: Fix irqoff tracers on failure of acquiring calltime
The functions irqsoff_graph_entry() and irqsoff_graph_return() both call func_prolog_dec() that will test if the data->disable is already set and if not, increment it and return. If it was set, it returns false and the caller exits. The caller of this function must decrement the disable counter, but misses doing so if the calltime fails to be acquired. Instead of exiting out when calltime is NULL, change the logic to do the work if it is not NULL and still do the clean up at the end of the function if it is NULL. Cc: stable@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20251008114943.6f60f30f@gandalf.local.home Fixes: a485ea9 ("tracing: Fix irqsoff and wakeup latency tracers when using function graph") Reported-by: Sasha Levin <sashal@kernel.org> Closes: https://lore.kernel.org/linux-trace-kernel/20251006175848.1906912-2-sashal@kernel.org/ Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 4f7bf54 commit c834a97

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

kernel/trace/trace_irqsoff.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static int irqsoff_graph_entry(struct ftrace_graph_ent *trace,
184184
unsigned long flags;
185185
unsigned int trace_ctx;
186186
u64 *calltime;
187-
int ret;
187+
int ret = 0;
188188

189189
if (ftrace_graph_ignore_func(gops, trace))
190190
return 0;
@@ -202,13 +202,11 @@ static int irqsoff_graph_entry(struct ftrace_graph_ent *trace,
202202
return 0;
203203

204204
calltime = fgraph_reserve_data(gops->idx, sizeof(*calltime));
205-
if (!calltime)
206-
return 0;
207-
208-
*calltime = trace_clock_local();
209-
210-
trace_ctx = tracing_gen_ctx_flags(flags);
211-
ret = __trace_graph_entry(tr, trace, trace_ctx);
205+
if (calltime) {
206+
*calltime = trace_clock_local();
207+
trace_ctx = tracing_gen_ctx_flags(flags);
208+
ret = __trace_graph_entry(tr, trace, trace_ctx);
209+
}
212210
local_dec(&data->disabled);
213211

214212
return ret;
@@ -233,11 +231,10 @@ static void irqsoff_graph_return(struct ftrace_graph_ret *trace,
233231

234232
rettime = trace_clock_local();
235233
calltime = fgraph_retrieve_data(gops->idx, &size);
236-
if (!calltime)
237-
return;
238-
239-
trace_ctx = tracing_gen_ctx_flags(flags);
240-
__trace_graph_return(tr, trace, trace_ctx, *calltime, rettime);
234+
if (calltime) {
235+
trace_ctx = tracing_gen_ctx_flags(flags);
236+
__trace_graph_return(tr, trace, trace_ctx, *calltime, rettime);
237+
}
241238
local_dec(&data->disabled);
242239
}
243240

0 commit comments

Comments
 (0)