[PATCH RT 4/8] mm: Dont warn about atomic memory allocations during suspend

From: Steven Rostedt
Date: Fri Jun 05 2020 - 19:42:59 EST


5.4.44-rt27-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Liwei Song <liwei.song@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
[bigeasy: commit description, allocate_slab() hunk]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
mm/slub.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 44a602fc8a16..bea18bbae247 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1635,7 +1635,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
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)
@@ -2751,7 +2751,8 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s,
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)
@@ -3216,7 +3217,8 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size,
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);
--
2.26.2