aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/slub.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 30354bfeb43d..dcbfda0b02ed 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2610,6 +2610,7 @@ static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
2610 struct kmem_cache *s; 2610 struct kmem_cache *s;
2611 char *text; 2611 char *text;
2612 size_t realsize; 2612 size_t realsize;
2613 unsigned long slabflags;
2613 2614
2614 s = kmalloc_caches_dma[index]; 2615 s = kmalloc_caches_dma[index];
2615 if (s) 2616 if (s)
@@ -2631,9 +2632,18 @@ static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
2631 (unsigned int)realsize); 2632 (unsigned int)realsize);
2632 s = kmalloc(kmem_size, flags & ~SLUB_DMA); 2633 s = kmalloc(kmem_size, flags & ~SLUB_DMA);
2633 2634
2635 /*
2636 * Must defer sysfs creation to a workqueue because we don't know
2637 * what context we are called from. Before sysfs comes up, we don't
2638 * need to do anything because our sysfs initcall will start by
2639 * adding all existing slabs to sysfs.
2640 */
2641 slabflags = SLAB_CACHE_DMA;
2642 if (slab_state >= SYSFS)
2643 slabflags |= __SYSFS_ADD_DEFERRED;
2644
2634 if (!s || !text || !kmem_cache_open(s, flags, text, 2645 if (!s || !text || !kmem_cache_open(s, flags, text,
2635 realsize, ARCH_KMALLOC_MINALIGN, 2646 realsize, ARCH_KMALLOC_MINALIGN, slabflags, NULL)) {
2636 SLAB_CACHE_DMA|__SYSFS_ADD_DEFERRED, NULL)) {
2637 kfree(s); 2647 kfree(s);
2638 kfree(text); 2648 kfree(text);
2639 goto unlock_out; 2649 goto unlock_out;
@@ -2642,7 +2652,8 @@ static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
2642 list_add(&s->list, &slab_caches); 2652 list_add(&s->list, &slab_caches);
2643 kmalloc_caches_dma[index] = s; 2653 kmalloc_caches_dma[index] = s;
2644 2654
2645 schedule_work(&sysfs_add_work); 2655 if (slab_state >= SYSFS)
2656 schedule_work(&sysfs_add_work);
2646 2657
2647unlock_out: 2658unlock_out:
2648 up_write(&slub_lock); 2659 up_write(&slub_lock);