Merge tag 'dt-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[deliverable/linux.git] / include / linux / slab_def.h
index 8bb6e0eaf3c69ef19c5a2fc4810c8a558881ed5d..cd401580bdd30f2f0c6fb586e8244f7e6756b1fa 100644 (file)
@@ -11,8 +11,6 @@
  */
 
 #include <linux/init.h>
-#include <asm/page.h>          /* kmalloc_sizes.h needs PAGE_SIZE */
-#include <asm/cache.h>         /* kmalloc_sizes.h needs L1_CACHE_BYTES */
 #include <linux/compiler.h>
 
 /*
@@ -97,23 +95,13 @@ struct kmem_cache {
         * pointer for each node since "nodelists" uses the remainder of
         * available pointers.
         */
-       struct kmem_list3 **nodelists;
+       struct kmem_cache_node **node;
        struct array_cache *array[NR_CPUS + MAX_NUMNODES];
        /*
         * Do not add fields after array[]
         */
 };
 
-/* Size description struct for general caches. */
-struct cache_sizes {
-       size_t                  cs_size;
-       struct kmem_cache       *cs_cachep;
-#ifdef CONFIG_ZONE_DMA
-       struct kmem_cache       *cs_dmacachep;
-#endif
-};
-extern struct cache_sizes malloc_sizes[];
-
 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 void *__kmalloc(size_t size, gfp_t flags);
 
@@ -133,26 +121,22 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
        void *ret;
 
        if (__builtin_constant_p(size)) {
-               int i = 0;
+               int i;
 
                if (!size)
                        return ZERO_SIZE_PTR;
 
-#define CACHE(x) \
-               if (size <= x) \
-                       goto found; \
-               else \
-                       i++;
-#include <linux/kmalloc_sizes.h>
-#undef CACHE
-               return NULL;
-found:
+               if (WARN_ON_ONCE(size > KMALLOC_MAX_SIZE))
+                       return NULL;
+
+               i = kmalloc_index(size);
+
 #ifdef CONFIG_ZONE_DMA
                if (flags & GFP_DMA)
-                       cachep = malloc_sizes[i].cs_dmacachep;
+                       cachep = kmalloc_dma_caches[i];
                else
 #endif
-                       cachep = malloc_sizes[i].cs_cachep;
+                       cachep = kmalloc_caches[i];
 
                ret = kmem_cache_alloc_trace(cachep, flags, size);
 
@@ -186,26 +170,22 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
        struct kmem_cache *cachep;
 
        if (__builtin_constant_p(size)) {
-               int i = 0;
+               int i;
 
                if (!size)
                        return ZERO_SIZE_PTR;
 
-#define CACHE(x) \
-               if (size <= x) \
-                       goto found; \
-               else \
-                       i++;
-#include <linux/kmalloc_sizes.h>
-#undef CACHE
-               return NULL;
-found:
+               if (WARN_ON_ONCE(size > KMALLOC_MAX_SIZE))
+                       return NULL;
+
+               i = kmalloc_index(size);
+
 #ifdef CONFIG_ZONE_DMA
                if (flags & GFP_DMA)
-                       cachep = malloc_sizes[i].cs_dmacachep;
+                       cachep = kmalloc_dma_caches[i];
                else
 #endif
-                       cachep = malloc_sizes[i].cs_cachep;
+                       cachep = kmalloc_caches[i];
 
                return kmem_cache_alloc_node_trace(cachep, flags, node, size);
        }
This page took 0.031247 seconds and 5 git commands to generate.