Support slab without ZONE_SLAB. If CONFIG_ZONE_DMA is not defined then drop support for ZONE_DMA from the slab allocator. Do not create the special DMA slab series for kmalloc and always return memory from ZONE_NORMAL. Signed-off-by: Christoph Lameter Index: linux-2.6.18-rc5-mm1/mm/slab.c =================================================================== --- linux-2.6.18-rc5-mm1.orig/mm/slab.c 2006-09-01 16:16:26.000000000 -0700 +++ linux-2.6.18-rc5-mm1/mm/slab.c 2006-09-02 20:19:12.000000000 -0700 @@ -649,11 +649,17 @@ /* Must match cache_sizes above. Out of line to keep cache footprint low. */ struct cache_names { char *name; +#ifdef CONFIG_ZONE_DMA char *name_dma; +#endif }; static struct cache_names __initdata cache_names[] = { +#ifdef CONFIG_ZONE_DMA #define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" }, +#else +#define CACHE(x) { .name = "size-" #x }, +#endif #include {NULL,} #undef CACHE @@ -777,7 +783,7 @@ #endif while (size > csizep->cs_size) csizep++; - +#ifdef CONFIG_ZONE_DMA /* * Really subtle: The last entry with cs->cs_size==ULONG_MAX * has cs_{dma,}cachep==NULL. Thus no special case @@ -785,6 +791,7 @@ */ if (unlikely(gfpflags & GFP_DMA)) return csizep->cs_dmacachep; +#endif return csizep->cs_cachep; } @@ -1441,13 +1448,14 @@ ARCH_KMALLOC_FLAGS|SLAB_PANIC, NULL, NULL); } - +#ifdef CONFIG_ZONE_DMA sizes->cs_dmacachep = kmem_cache_create(names->name_dma, sizes->cs_size, ARCH_KMALLOC_MINALIGN, ARCH_KMALLOC_FLAGS|SLAB_CACHE_DMA| SLAB_PANIC, NULL, NULL); +#endif sizes++; names++; } @@ -2275,8 +2283,10 @@ cachep->slab_size = slab_size; cachep->flags = flags; cachep->gfpflags = 0; +#ifdef CONFIG_ZONE_DMA if (flags & SLAB_CACHE_DMA) cachep->gfpflags |= GFP_DMA; +#endif cachep->buffer_size = size; if (flags & CFLGS_OFF_SLAB) { @@ -2599,10 +2609,12 @@ static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags) { +#ifdef CONFIG_ZONE_DMA if (flags & SLAB_DMA) BUG_ON(!(cachep->gfpflags & GFP_DMA)); else BUG_ON(cachep->gfpflags & GFP_DMA); +#endif } static void *slab_get_obj(struct kmem_cache *cachep, struct slab *slabp, Index: linux-2.6.18-rc5-mm1/include/linux/slab.h =================================================================== --- linux-2.6.18-rc5-mm1.orig/include/linux/slab.h 2006-09-02 20:17:32.000000000 -0700 +++ linux-2.6.18-rc5-mm1/include/linux/slab.h 2006-09-02 20:19:12.000000000 -0700 @@ -76,7 +76,9 @@ struct cache_sizes { size_t cs_size; kmem_cache_t *cs_cachep; +#ifdef CONFIG_ZONE_DMA kmem_cache_t *cs_dmacachep; +#endif }; extern struct cache_sizes malloc_sizes[]; @@ -150,9 +152,13 @@ __you_cannot_kmalloc_that_much(); } found: +#ifdef CONFIG_ZONE_DMA return kmem_cache_alloc((flags & GFP_DMA) ? malloc_sizes[i].cs_dmacachep : malloc_sizes[i].cs_cachep, flags); +#else + return kmem_cache_alloc(malloc_sizes[i].cs_cachep, flags); +#endif } return __kmalloc(size, flags); } @@ -180,9 +186,13 @@ __you_cannot_kzalloc_that_much(); } found: +#ifdef CONFIG_ZONE_DMA return kmem_cache_zalloc((flags & GFP_DMA) ? malloc_sizes[i].cs_dmacachep : malloc_sizes[i].cs_cachep, flags); +#else + return kmem_cache_zalloc(malloc_sizes[i].cs_cachep, flags); +#endif } return __kzalloc(size, flags); }