The memory allocation via kmalloc(, GFP_ATOMIC) in atomic context (disabled preemption or interrupts) is not allowed on RT because the buddy allocator is using sleeping locks which can't be acquired in this context. Such an an allocation may not trigger a warning in the buddy allocator if it is always satisfied in the SLUB allocator. Add a warning on RT if a memory allocation was attempted in not preemptible region. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- mm/slub.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 2cff48d13e3a7..7b2773c45e1ff 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2742,6 +2742,9 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct page *page; unsigned long tid; + if (IS_ENABLED(CONFIG_PREEMPT_RT) && IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP)) + WARN_ON_ONCE(!preemptible() && system_state >= SYSTEM_SCHEDULING); + s = slab_pre_alloc_hook(s, gfpflags); if (!s) return NULL; @@ -3202,6 +3205,9 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, LIST_HEAD(to_free); int i; + if (IS_ENABLED(CONFIG_PREEMPT_RT) && IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP)) + WARN_ON_ONCE(!preemptible() && system_state >= SYSTEM_SCHEDULING); + /* memcg and kmem_cache debug support */ s = slab_pre_alloc_hook(s, flags); if (unlikely(!s)) -- 2.25.1