Skip to content

Commit

Permalink
slab: Common definition for the array of kmalloc caches
Browse files Browse the repository at this point in the history
Have a common definition fo the kmalloc cache arrays in
SLAB and SLUB

Acked-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
  • Loading branch information
Christoph Lameter authored and Pekka Enberg committed Feb 1, 2013
1 parent 95a05b4 commit 9425c58
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 24 deletions.
5 changes: 5 additions & 0 deletions include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ struct kmem_cache {
#define KMALLOC_MIN_SIZE (1 << KMALLOC_SHIFT_LOW)
#endif

extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
#ifdef CONFIG_ZONE_DMA
extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
#endif

/*
* Figure out which kmalloc slab an allocation of a certain size
* belongs to.
Expand Down
3 changes: 0 additions & 3 deletions include/linux/slab_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ struct kmem_cache {
*/
};

extern struct kmem_cache *kmalloc_caches[PAGE_SHIFT + MAX_ORDER];
extern struct kmem_cache *kmalloc_dma_caches[PAGE_SHIFT + MAX_ORDER];

void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
void *__kmalloc(size_t size, gfp_t flags);

Expand Down
6 changes: 0 additions & 6 deletions include/linux/slub_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ struct kmem_cache {
#define SLUB_DMA (__force gfp_t)0
#endif

/*
* We keep the general caches in an array of slab caches that are used for
* 2^x bytes of allocations.
*/
extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];

/*
* Find the slab cache for a given combination of allocation flags and size.
*
Expand Down
8 changes: 0 additions & 8 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,6 @@ static void free_block(struct kmem_cache *cachep, void **objpp, int len,
static int enable_cpucache(struct kmem_cache *cachep, gfp_t gfp);
static void cache_reap(struct work_struct *unused);

struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
EXPORT_SYMBOL(kmalloc_caches);

#ifdef CONFIG_ZONE_DMA
struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
EXPORT_SYMBOL(kmalloc_dma_caches);
#endif

static int slab_early_init = 1;

#define INDEX_AC kmalloc_index(sizeof(struct arraycache_init))
Expand Down
8 changes: 8 additions & 0 deletions mm/slab_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
return s;
}

struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
EXPORT_SYMBOL(kmalloc_caches);

#ifdef CONFIG_ZONE_DMA
struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
EXPORT_SYMBOL(kmalloc_dma_caches);
#endif

#endif /* !CONFIG_SLOB */


Expand Down
7 changes: 0 additions & 7 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3174,13 +3174,6 @@ int __kmem_cache_shutdown(struct kmem_cache *s)
* Kmalloc subsystem
*******************************************************************/

struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
EXPORT_SYMBOL(kmalloc_caches);

#ifdef CONFIG_ZONE_DMA
static struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
#endif

static int __init setup_slub_min_order(char *str)
{
get_option(&str, &slub_min_order);
Expand Down

0 comments on commit 9425c58

Please sign in to comment.