Re: [PATCH] slab: fix kmalloc_nolock() context check for PREEMPT_RT

From: Vlastimil Babka
Date: Mon Jan 05 2026 - 14:23:49 EST


On 12/19/25 14:51, Swaraj Gaikwad wrote:
> I agree that we can simplify this. I think !preemptible() would be
> the most descriptive choice here, as it directly expresses the
> constraint, we cannot take a sleeping lock when preemption is
> disabled.
> The updated check would be:
> if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible())
>
> I'll send a v2 with this change unless there are objections.

I think it's the best solution for now, so please do. We can change it back
later with sheaves, as Hao Li pointed out. It will limit PREEMPT_RT
kmalloc_nolock() for now. Steven explained to me it's the tracepoints
disabling preemption, but that will be also improved soon:

https://lore.kernel.org/all/20251219120607.7371034e@xxxxxxxxxxxxxxxxxx/


> Swaraj