From: Andrea Righi <arighi@nvidia.com>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
sched-ext@lists.linux.dev
Subject: Re: [RFT] sched_ext: Skip stack trace capture in NMI context
Date: Tue, 23 Dec 2025 07:39:23 +0100 [thread overview]
Message-ID: <aUo5G1K4uFC6YRe_@gpd4> (raw)
In-Reply-To: <20251223005038.62406-1-joelagnelf@nvidia.com>
On Mon, Dec 22, 2025 at 07:50:37PM -0500, Joel Fernandes wrote:
> stack_trace_save() is not guaranteed to be NMI-safe on all
> architectures.
>
> The hardlockup detector calls into sched_ext via the following call
> chain when an NMI occurs:
>
> watchdog_overflow_callback()
> watchdog_hardlockup_check()
> scx_hardlockup()
> stack_trace_save()
>
> Skip stack trace capture when in_nmi() returns true to prevent
> potential deadlocks.
>
> Fixes: 582f700e1bdc ("sched_ext: Hook up hardlockup detector")
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
> ---
> kernel/sched/ext.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 05f5a49e9649..a96255ca3a08 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -4678,7 +4678,8 @@ static bool scx_vexit(struct scx_sched *sch,
>
> ei->exit_code = exit_code;
> #ifdef CONFIG_STACKTRACE
> - if (kind >= SCX_EXIT_ERROR)
> + /* Skip stack trace capture in NMI context as its unsafe. */
nit: s/its/it's/
> + if (kind >= SCX_EXIT_ERROR && !in_nmi())
> ei->bt_len = stack_trace_save(ei->bt, SCX_EXIT_BT_LEN, 1);
If stack_trace_save() isn't NMI-safe on certain architectures, shouldn't we
fix this inside stack_trace_save()?
There are probably other places where we call stack_trace_save() without
checking in_nmi(). Making stack_trace_save() handle the NMI case would
solve all of them.
> #endif
> vscnprintf(ei->msg, SCX_EXIT_MSG_LEN, fmt, args);
> --
> 2.34.1
>
Thanks,
-Andrea
prev parent reply other threads:[~2025-12-23 6:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 0:50 [RFT] sched_ext: Skip stack trace capture in NMI context Joel Fernandes
2025-12-23 2:44 ` Tejun Heo
2025-12-23 4:34 ` Joel Fernandes
2025-12-23 20:31 ` Steven Rostedt
2025-12-23 23:58 ` Joel Fernandes
2025-12-24 14:18 ` Steven Rostedt
2025-12-24 17:42 ` Joel Fernandes
2025-12-23 6:39 ` Andrea Righi [this message]
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=aUo5G1K4uFC6YRe_@gpd4 \
--to=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.com \
--cc=joelagnelf@nvidia.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.com \
/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