Re: [PATCH] tracing: Keep preemption disabled until the recursion bit is cleared

From: Karl Mehltretter

Date: Tue Dec 01 2026 - 20:18:45 EST


On Mon, Nov 30, 2026 at 11:31:08AM +0100, Steven Rostedt 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?
>

This is simpler and avoids the preempt_count updates on the rejection
path and gives the same results.

That said, your triple-fault concern still applies here, since the
recursion bit is still unset when preempt_disable_notrace() runs.

I tested your patch on x86_64 (with and without VMAP_STACK) and arm64.
With the transition bit disabled it matches my patch (~90% fewer
recorded recursion sites) and the ftrace startup self-tests pass.

On fault injection, a traced call right after preempt_disable_notrace()
is still caught by the current ordering. Your version hangs with
VMAP_STACK and triple-faults without it (under both TCG and KVM).
Keeping the transition bit does not help.

On the other hand, switching preempt_disable_notrace() to the real
traced preempt_count_add() hangs the baseline too. Paths like
preempt_schedule_notrace() already rely on it not being traced.

So if you're fine relying on preempt_disable_notrace() staying
non-instrumented, I'd rather go with your version.

Thanks,
Karl