summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2020-03-06 15:59:06 +0100
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2020-04-03 18:49:43 +0200
commitb5d5bc970f2098eec7869a68d84329140b364b71 (patch)
tree357d171b8ed1ec2012a12fc19553a9d2451319c5 /mm
parentd70aed48ace6dfb9b07b07900f97f3342590c6ad (diff)
downloadlinux-rt-b5d5bc970f2098eec7869a68d84329140b364b71.tar.gz
mm: Warn on memory allocation in non-preemptible context on RT
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@linutronix.de> Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/slub.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 6589b41d5a60..5711d6c0cb7f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2707,6 +2707,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;
@@ -3168,6 +3171,9 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size,
struct kmem_cache_cpu *c;
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))