From: Sasha Levin <sashal@kernel.org>
To: rostedt@goodmis.org, mhiramat@kernel.org
Cc: mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 1/2] tracing/wakeup: Balance prolog on fgraph failure
Date: Mon, 6 Oct 2025 13:58:47 -0400 [thread overview]
Message-ID: <20251006175848.1906912-1-sashal@kernel.org> (raw)
Commit a485ea9e3ef3 ("tracing: Fix irqsoff and wakeup latency tracers when
using function graph") added fgraph_reserve_data()/fgraph_retrieve_data() to
the wakeup tracer's function-graph hooks.
When func_prolog_preempt_disable() succeeded but those calls failed, the code
returned without undoing the prolog (no local_dec(&data->disabled), no
preempt_enable_notrace()). That leaked a preempt disable into later code and
could trigger "BUG: scheduling while atomic".
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 <sashal@kernel.org>
---
kernel/trace/trace_sched_wakeup.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index bf1cb80742aed..fa48bbdf0851c 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -138,8 +138,11 @@ static int wakeup_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);
+ preempt_enable_notrace();
return 0;
+ }
*calltime = trace_clock_local();
@@ -169,8 +172,11 @@ static void wakeup_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);
+ preempt_enable_notrace();
return;
+ }
__trace_graph_return(tr, trace, trace_ctx, *calltime, rettime);
local_dec(&data->disabled);
--
2.51.0
next reply other threads:[~2025-10-06 17:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-06 17:58 Sasha Levin [this message]
2025-10-06 17:58 ` [PATCH 2/2] tracing/irqsoff: Balance prolog on fgraph failure Sasha Levin
2025-10-08 15:27 ` Steven Rostedt
2025-10-08 15:24 ` [PATCH 1/2] tracing/wakeup: " Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251006175848.1906912-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox