blob: eed44b128fd666ab8608ef7574c5ea12f7bc12c9 [file] [log] [blame]
From: Liwei Song <liwei.song@windriver.com>
Date: Mon, 4 May 2020 15:58:22 +0200
Subject: [PATCH] mm: Don't warn about atomic memory allocations during suspend
The ACPI code allocates larger amount of memory during resume. This
triggers a warning because the allocation happens with disabled
interrupts.
At this stage only one CPU is active so there should be no lock
contention. If SLUB needs to call into the buddy allocator for more
memory then it should not enable interrupts.
Limit the check to system state with more CPUs and scheduling and only
enable interrupts in SLUB at this stage.
Signed-off-by: Liwei Song <liwei.song@windriver.com>
[bigeasy: commit description, allocate_slab() hunk]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
mm/slub.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1655,7 +1655,7 @@ static struct page *allocate_slab(struct
enableirqs = true;
#ifdef CONFIG_PREEMPT_RT
- if (system_state > SYSTEM_BOOTING)
+ if (system_state > SYSTEM_BOOTING && system_state < SYSTEM_SUSPEND)
enableirqs = true;
#endif
if (enableirqs)
@@ -2768,7 +2768,8 @@ static __always_inline void *slab_alloc_
unsigned long tid;
if (IS_ENABLED(CONFIG_PREEMPT_RT) && IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP))
- WARN_ON_ONCE(!preemptible() && system_state >= SYSTEM_SCHEDULING);
+ WARN_ON_ONCE(!preemptible() &&
+ (system_state > SYSTEM_BOOTING && system_state < SYSTEM_SUSPEND));
s = slab_pre_alloc_hook(s, gfpflags);
if (!s)
@@ -3233,7 +3234,8 @@ int kmem_cache_alloc_bulk(struct kmem_ca
int i;
if (IS_ENABLED(CONFIG_PREEMPT_RT) && IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP))
- WARN_ON_ONCE(!preemptible() && system_state >= SYSTEM_SCHEDULING);
+ WARN_ON_ONCE(!preemptible() &&
+ (system_state > SYSTEM_BOOTING && system_state < SYSTEM_SUSPEND));
/* memcg and kmem_cache debug support */
s = slab_pre_alloc_hook(s, flags);