mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: Mon, 30 Nov 2026 11:31:08 -0500	[thread overview]
Message-ID: <20261130113108.293e4d1d@gandalf.local.home> (raw)
In-Reply-To: <awymd-hlDBuj_JRD@gmail.com>

On Sun, 29 Nov 2026 23:34:57 +0100
Karl Mehltretter <kmehltretter@gmail.com> wrote:

> Would you rather drop the patch, or go with one of these?
> 
>   1. Send the partial fix above as v2 (keeps your check, fixes >99%,
>      leaves the two short interrupt windows).
>   2. Reorder as in my patch using small noinstr helpers for the count
>      updates (closes both windows, objtool checks noinstr on x86, loses
>      the runtime check, adds a helper call).

Why are disabling preemption before the checks anyway. It's not the checks
that are causing the issue, it's the setting of the bits themselves.

Why not this patch which disables preemption *before* setting the bits,
which should give you the same results?

-- Steve

diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
index e6ca052b2a85..95c3a066dab7 100644
--- a/include/linux/trace_recursion.h
+++ b/include/linux/trace_recursion.h
@@ -149,12 +149,12 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
 		}
 	}
 
+	preempt_disable_notrace();
+
 	val |= 1 << bit;
 	current->trace_recursion = val;
 	barrier();
 
-	preempt_disable_notrace();
-
 	return bit;
 }
 
@@ -163,9 +163,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();
 }
 
 /**

      reply	other threads:[~2026-11-30 16:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  1:13 Karl Mehltretter
2026-11-24 16:14 ` Steven Rostedt
2026-11-29 22:34   ` Karl Mehltretter
2026-11-30 16:31     ` 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=20261130113108.293e4d1d@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

all inboxes | Powered by JetHome®