Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
[linux-2.6-microblaze.git] / mm / slab_common.c
index 2b3206a..77c3adf 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <linux/memcontrol.h>
+#include <linux/stackdepot.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/kmem.h>
@@ -154,8 +155,7 @@ static unsigned int calculate_alignment(slab_flags_t flags,
                align = max(align, ralign);
        }
 
-       if (align < ARCH_SLAB_MINALIGN)
-               align = ARCH_SLAB_MINALIGN;
+       align = max(align, arch_slab_minalign());
 
        return ALIGN(align, sizeof(void *));
 }
@@ -314,9 +314,13 @@ kmem_cache_create_usercopy(const char *name,
         * If no slub_debug was enabled globally, the static key is not yet
         * enabled by setup_slub_debug(). Enable it if the cache is being
         * created with any of the debugging flags passed explicitly.
+        * It's also possible that this is the first cache created with
+        * SLAB_STORE_USER and we should init stack_depot for it.
         */
        if (flags & SLAB_DEBUG_FLAGS)
                static_branch_enable(&slub_debug_enabled);
+       if (flags & SLAB_STORE_USER)
+               stack_depot_init();
 #endif
 
        mutex_lock(&slab_mutex);
@@ -858,6 +862,8 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
                        return;
                }
                flags |= SLAB_ACCOUNT;
+       } else if (IS_ENABLED(CONFIG_ZONE_DMA) && (type == KMALLOC_DMA)) {
+               flags |= SLAB_CACHE_DMA;
        }
 
        kmalloc_caches[type][idx] = create_kmalloc_cache(
@@ -886,7 +892,7 @@ void __init create_kmalloc_caches(slab_flags_t flags)
        /*
         * Including KMALLOC_CGROUP if CONFIG_MEMCG_KMEM defined
         */
-       for (type = KMALLOC_NORMAL; type <= KMALLOC_RECLAIM; type++) {
+       for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) {
                for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
                        if (!kmalloc_caches[type][i])
                                new_kmalloc_cache(i, type, flags);
@@ -907,20 +913,6 @@ void __init create_kmalloc_caches(slab_flags_t flags)
 
        /* Kmalloc array is now usable */
        slab_state = UP;
-
-#ifdef CONFIG_ZONE_DMA
-       for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
-               struct kmem_cache *s = kmalloc_caches[KMALLOC_NORMAL][i];
-
-               if (s) {
-                       kmalloc_caches[KMALLOC_DMA][i] = create_kmalloc_cache(
-                               kmalloc_info[i].name[KMALLOC_DMA],
-                               kmalloc_info[i].size,
-                               SLAB_CACHE_DMA | flags, 0,
-                               kmalloc_info[i].size);
-               }
-       }
-#endif
 }
 #endif /* !CONFIG_SLOB */