Skip to content

Commit 70a96bb

Browse files
KAGA-KOKOzeddii
authored andcommitted
slub: Enable irqs for __GFP_WAIT
SYSTEM_RUNNING might be too late for enabling interrupts. Allocations with GFP_WAIT can happen before that. So use this as an indicator. [bigeasy: Add warning on RT for allocations in atomic context. Don't enable interrupts on allocations during SYSTEM_SUSPEND. This is done during suspend by ACPI, noticed by Liwei Song <[email protected]> ] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 9154bae commit 70a96bb

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mm/slub.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,10 +1745,18 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
17451745
void *start, *p, *next;
17461746
int idx;
17471747
bool shuffle;
1748+
bool enableirqs = false;
17481749

17491750
flags &= gfp_allowed_mask;
17501751

17511752
if (gfpflags_allow_blocking(flags))
1753+
enableirqs = true;
1754+
1755+
#ifdef CONFIG_PREEMPT_RT
1756+
if (system_state > SYSTEM_BOOTING && system_state < SYSTEM_SUSPEND)
1757+
enableirqs = true;
1758+
#endif
1759+
if (enableirqs)
17521760
local_irq_enable();
17531761

17541762
flags |= s->allocflags;
@@ -1807,7 +1815,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
18071815
page->frozen = 1;
18081816

18091817
out:
1810-
if (gfpflags_allow_blocking(flags))
1818+
if (enableirqs)
18111819
local_irq_disable();
18121820
if (!page)
18131821
return NULL;
@@ -2865,6 +2873,10 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s,
28652873
unsigned long tid;
28662874
struct obj_cgroup *objcg = NULL;
28672875

2876+
if (IS_ENABLED(CONFIG_PREEMPT_RT) && IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP))
2877+
WARN_ON_ONCE(!preemptible() &&
2878+
(system_state > SYSTEM_BOOTING && system_state < SYSTEM_SUSPEND));
2879+
28682880
s = slab_pre_alloc_hook(s, &objcg, 1, gfpflags);
28692881
if (!s)
28702882
return NULL;
@@ -3331,6 +3343,10 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size,
33313343
int i;
33323344
struct obj_cgroup *objcg = NULL;
33333345

3346+
if (IS_ENABLED(CONFIG_PREEMPT_RT) && IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP))
3347+
WARN_ON_ONCE(!preemptible() &&
3348+
(system_state > SYSTEM_BOOTING && system_state < SYSTEM_SUSPEND));
3349+
33343350
/* memcg and kmem_cache debug support */
33353351
s = slab_pre_alloc_hook(s, &objcg, size, flags);
33363352
if (unlikely(!s))

0 commit comments

Comments
 (0)