Re: [PATCH] mm/mmu_notifier: Remove non_block_start/end() from notifier invocation
From: David Woodhouse
Date: Tue Aug 11 2026 - 11:26:24 EST
On Tue, 2026-08-11 at 10:42 -0400, Steven Rostedt wrote:
> On Tue, 11 Aug 2026 15:33:18 +0100
> David Woodhouse <dwmw2@xxxxxxxxxxxxx> wrote:
>
> > > If might_sleep doesn't work sanely at all in preempt_rt then just
> > > globally turn it off?
> >
> > Turn might_sleep off? Or PREEMPT_RT? :)
> >
> > The RT maintainers are on this thread if you want to pick either of
> > those fights... that was not the course of action I chose to take.
>
> I guess the question is, what exactly is the reason for sleeping to be
> prohibited? In RT, sleeping is allowed in most context because most context
> are threads (like interrupt handlers and such). Now, you still can't sleep
> in NMIs and hard interrupt handlers that were not converted to threads, but
> I'm not sure that's the case here anyway.
>
> If the non_block_start() is just a big hammer to make sure things are fine
> in non-RT, it will likely still be fine in RT even though it may block and
> sleep. But what it blocks on are sleeping spin locks that likely would not
> cause an issue here if they didn't cause an issue in non-RT.
That's exactly the case in
https://lore.kernel.org/all/787aa26cf62dfd361eea8ed19f384fc517892501.camel@xxxxxxxxxxxxx/
which is currently being complained about, but it's actually harmless
and arguably a false positive.
I had a second reason for disabling the overzealous check too: to allow
SRCU grace periods within the notifier callbacks.
> Thus, perhaps something like this:
>
> if (ops->invalidate_range_start) {
> int _ret;
>
> if (!IS_ENABLED(CONFIG_PREEMPT_RT) && !mmu_notifier_range_blockable(range))
> non_block_start();
> _ret = ops->invalidate_range_start(subscription, range);
> if (!IS_ENABLED(CONFIG_PREEMPT_RT) && !mmu_notifier_range_blockable(range))
> non_block_end();
>
> ?
Or put it in a per-mmu-notifier-ops flag (a bit like the one in commit
5ff7091f5a2c, but with almost opposite semantics), and let the drivers
Jason cares about still keep the guard, while KVM doesn't need to. With
or without the RT part...
static bool mn_enforce_non_block(const struct mmu_notifier_ops *ops,
const struct mmu_notifier_range *range)
{
/*
* On PREEMPT_RT even a plain spin_lock() schedules, so the
* annotation splats on legitimate non-blocking implementations.
*/
if (IS_ENABLED(CONFIG_PREEMPT_RT))
return false;
if (ops->flags & MMU_NOTIFIER_NONBLOCKABLE_MAY_WAIT)
return false;
return !mmu_notifier_range_blockable(range);
}
But honestly, I can't see the point in keeping it around at all, given
that I literally had to hack the kernel to make it trigger in the first
place.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature