From: Steven Rostedt <rostedt@goodmis.org>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@kernel.org>, Song Liu <song@kernel.org>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Keep preemption disabled until the recursion bit is cleared
Date: Tue, 24 Nov 2026 11:14:25 -0500 [thread overview]
Message-ID: <20261124111425.487a2ec8@gandalf.local.home> (raw)
In-Reply-To: <20261113011333.20813-1-kmehltretter@gmail.com>
On Fri, 13 Nov 2026 02:13:33 +0100
Karl Mehltretter <kmehltretter@gmail.com> wrote:
> diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
> index e6ca052b2a85a..a7c66313bf360 100644
> --- a/include/linux/trace_recursion.h
> +++ b/include/linux/trace_recursion.h
> @@ -132,6 +132,8 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
> if (trace_warn_on_no_rcu(ip))
> return -1;
>
> + preempt_disable_notrace();
> +
> bit = trace_get_context_bit() + start;
> if (unlikely(val & (1 << bit))) {
> /*
> @@ -145,6 +147,7 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
> bit = TRACE_CTX_TRANSITION + start;
> if (val & (1 << bit)) {
> do_ftrace_record_recursion(ip, pip);
> + preempt_enable_notrace();
> return -1;
Honestly, the reason I did it this way was because if for some reason
something in preempt_disable_notrace() was traced, this would catch it.
I guess we could change it to do it this way, but if something were to be
traced in preempt_disable_notrace() it would triple fault and reboot the
machine with no warning. :-/
-- Steve
> }
> }
> @@ -153,8 +156,6 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
> current->trace_recursion = val;
> barrier();
>
> - preempt_disable_notrace();
> -
> return bit;
> }
>
> @@ -163,9 +164,9 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
> */
> static __always_inline void trace_clear_recursion(int bit)
> {
> - preempt_enable_notrace();
> barrier();
> trace_recursion_clear(bit);
> + preempt_enable_notrace();
> }
>
> /**
> base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
prev parent reply other threads:[~2026-11-24 16:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 1:13 [PATCH] tracing: Keep preemption disabled until the recursion bit is cleared Karl Mehltretter
2026-11-24 16:14 ` Steven Rostedt [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=20261124111425.487a2ec8@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=kmehltretter@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
--cc=tglx@kernel.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