Merge tag 'slab-for-6.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab

Pull slab fix from Vlastimil Babka:

 - A stable fix for kmalloc_nolock() in non-preemptible contexts on
   PREEMPT_RT (Swaraj Gaikwad)

* tag 'slab-for-6.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
  slab: fix kmalloc_nolock() context check for PREEMPT_RT
This commit is contained in:
Linus Torvalds
2026-01-21 09:19:15 -08:00

View File

@@ -5694,8 +5694,12 @@ void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node)
if (unlikely(!size))
return ZERO_SIZE_PTR;
if (IS_ENABLED(CONFIG_PREEMPT_RT) && (in_nmi() || in_hardirq()))
/* kmalloc_nolock() in PREEMPT_RT is not supported from irq */
if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible())
/*
* kmalloc_nolock() in PREEMPT_RT is not supported from
* non-preemptible context because local_lock becomes a
* sleeping lock on RT.
*/
return NULL;
retry:
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))