Make ZONE_DMA optional in the page allocator - ifdef all code for ZONE_DMA and related definitions. - Without ZONE_DMA, ZONE_HIGHMEM and ZONE_DMA32 we fall back to an empty GFP_ZONEMASK and a ZONES_SHIFT of zero (since there is only one zone....). - We need to fix the use of ZONE_DMA in the memory policy layer. ZONE_DMA is used there as the first zone so use 0 instead. Signed-off-by: Christoph Lameter Index: linux-2.6.18-rc5-mm1/include/linux/mmzone.h =================================================================== --- linux-2.6.18-rc5-mm1.orig/include/linux/mmzone.h 2006-09-01 10:13:35.893383590 -0700 +++ linux-2.6.18-rc5-mm1/include/linux/mmzone.h 2006-09-05 12:07:29.076931791 -0700 @@ -90,6 +90,7 @@ struct per_cpu_pageset { #endif enum zone_type { +#ifdef CONFIG_ZONE_DMA /* * ZONE_DMA is used when there are devices that are not able * to do DMA to all of addressable memory (ZONE_NORMAL). Then we @@ -110,6 +111,7 @@ enum zone_type { * <16M. */ ZONE_DMA, +#endif #ifdef CONFIG_ZONE_DMA32 /* * x86_64 needs two ZONE_DMAs because it supports devices that are @@ -147,7 +149,11 @@ enum zone_type { */ #if !defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_HIGHMEM) +#if !defined(CONFIG_ZONE_DMA) +#define ZONES_SHIFT 0 +#else #define ZONES_SHIFT 1 +#endif #else #define ZONES_SHIFT 2 #endif @@ -411,6 +417,15 @@ static inline int is_highmem_idx(enum zo #endif } +static inline int is_dma_idx(enum zone_type idx) +{ +#ifdef CONFIG_ZONE_DMA + return (idx == ZONE_DMA); +#else + return 0; +#endif +} + static inline int is_normal_idx(enum zone_type idx) { return (idx == ZONE_NORMAL); @@ -447,7 +462,11 @@ static inline int is_dma32(struct zone * static inline int is_dma(struct zone *zone) { +#ifdef CONFIG_ZONE_DMA return zone == zone->zone_pgdat->node_zones + ZONE_DMA; +#else + return 0; +#endif } /* These two functions are used to setup the per zone pages min values */ Index: linux-2.6.18-rc5-mm1/mm/page_alloc.c =================================================================== --- linux-2.6.18-rc5-mm1.orig/mm/page_alloc.c 2006-09-04 09:59:07.382748938 -0700 +++ linux-2.6.18-rc5-mm1/mm/page_alloc.c 2006-09-05 12:07:29.079861297 -0700 @@ -71,7 +71,9 @@ static void __free_pages_ok(struct page * don't need any ZONE_NORMAL reservation */ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { +#ifdef CONFIG_ZONE_DMA 256, +#endif #ifdef CONFIG_ZONE_DMA32 256, #endif @@ -90,7 +92,9 @@ struct zone *zone_table[1 << ZONETABLE_S EXPORT_SYMBOL(zone_table); static char *zone_names[MAX_NR_ZONES] = { +#ifdef CONFIG_ZONE_DMA "DMA", +#endif #ifdef CONFIG_ZONE_DMA32 "DMA32", #endif @@ -2445,12 +2449,11 @@ static void __meminit free_area_init_cor realsize -= account_memmap(pgdat, j); /* Account for reserved DMA pages */ - if (j == ZONE_DMA && realsize > dma_reserve) { + if (is_dma_idx(j) && realsize > dma_reserve) { realsize -= dma_reserve; printk(KERN_DEBUG "%lu pages DMA reserved\n", dma_reserve); } - if (!is_highmem_idx(j)) nr_kernel_pages += realsize; nr_all_pages += realsize; Index: linux-2.6.18-rc5-mm1/mm/mempolicy.c =================================================================== --- linux-2.6.18-rc5-mm1.orig/mm/mempolicy.c 2006-09-04 09:59:07.380795933 -0700 +++ linux-2.6.18-rc5-mm1/mm/mempolicy.c 2006-09-05 12:07:29.081814301 -0700 @@ -105,7 +105,7 @@ static struct kmem_cache *sn_cache; /* Highest zone. An specific allocation for a zone below that is not policied. */ -enum zone_type policy_zone = ZONE_DMA; +enum zone_type policy_zone = 0; struct mempolicy default_policy = { .refcnt = ATOMIC_INIT(1), /* never free it */ Index: linux-2.6.18-rc5-mm1/include/linux/gfp.h =================================================================== --- linux-2.6.18-rc5-mm1.orig/include/linux/gfp.h 2006-09-01 10:13:35.614103927 -0700 +++ linux-2.6.18-rc5-mm1/include/linux/gfp.h 2006-09-05 12:07:29.089626319 -0700 @@ -80,8 +80,10 @@ struct vm_area_struct; static inline enum zone_type gfp_zone(gfp_t flags) { +#ifdef CONFIG_ZONE_DMA if (flags & __GFP_DMA) return ZONE_DMA; +#endif #ifdef CONFIG_ZONE_DMA32 if (flags & __GFP_DMA32) return ZONE_DMA32; Index: linux-2.6.18-rc5-mm1/mm/slab.c =================================================================== --- linux-2.6.18-rc5-mm1.orig/mm/slab.c 2006-09-01 10:13:42.974001903 -0700 +++ linux-2.6.18-rc5-mm1/mm/slab.c 2006-09-05 12:07:29.092555825 -0700 @@ -778,6 +778,7 @@ static inline struct kmem_cache *__find_ 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 +786,7 @@ static inline struct kmem_cache *__find_ */ if (unlikely(gfpflags & GFP_DMA)) return csizep->cs_dmacachep; +#endif return csizep->cs_cachep; } @@ -1441,13 +1443,14 @@ void __init kmem_cache_init(void) 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 +2278,10 @@ kmem_cache_create (const char *name, siz 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) { Index: linux-2.6.18-rc5-mm1/include/linux/slab.h =================================================================== --- linux-2.6.18-rc5-mm1.orig/include/linux/slab.h 2006-09-01 10:13:36.505650544 -0700 +++ linux-2.6.18-rc5-mm1/include/linux/slab.h 2006-09-05 12:07:29.113062371 -0700 @@ -72,7 +72,11 @@ extern const char *kmem_cache_name(kmem_ struct cache_sizes { size_t cs_size; kmem_cache_t *cs_cachep; +#ifdef CONFIG_ZONE_DMA kmem_cache_t *cs_dmacachep; +#else +#define cs_dmacachep cs_cachep +#endif }; extern struct cache_sizes malloc_sizes[]; Index: linux-2.6.18-rc5-mm1/mm/vmstat.c =================================================================== --- linux-2.6.18-rc5-mm1.orig/mm/vmstat.c 2006-09-01 10:13:43.009155987 -0700 +++ linux-2.6.18-rc5-mm1/mm/vmstat.c 2006-09-05 12:08:18.232097559 -0700 @@ -437,6 +437,12 @@ struct seq_operations fragmentation_op = .show = frag_show, }; +#ifdef CONFIG_ZONE_DMA +#define TEXT_FOR_DMA(xx) xx "_dma", +#else +#define TEXT_FOR_DMA(xx) +#endif + #ifdef CONFIG_ZONE_DMA32 #define TEXT_FOR_DMA32(xx) xx "_dma32", #else @@ -449,7 +455,7 @@ struct seq_operations fragmentation_op = #define TEXT_FOR_HIGHMEM(xx) #endif -#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \ +#define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \ TEXT_FOR_HIGHMEM(xx) static char *vmstat_text[] = { Index: linux-2.6.18-rc5-mm1/include/linux/vmstat.h =================================================================== --- linux-2.6.18-rc5-mm1.orig/include/linux/vmstat.h 2006-09-01 10:13:36.919687527 -0700 +++ linux-2.6.18-rc5-mm1/include/linux/vmstat.h 2006-09-05 12:08:18.230144555 -0700 @@ -17,6 +17,12 @@ * generated will simply be the increment of a global address. */ +#ifdef CONFIG_ZONE_DMA +#define DMA_ZONE(xx) xx##_DMA, +#else +#define DMA_ZONE(xx) +#endif + #ifdef CONFIG_ZONE_DMA32 #define DMA32_ZONE(xx) xx##_DMA32, #else @@ -29,7 +35,7 @@ #define HIGHMEM_ZONE(xx) #endif -#define FOR_ALL_ZONES(xx) xx##_DMA, DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) +#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, FOR_ALL_ZONES(PGALLOC), @@ -87,9 +93,13 @@ extern void vm_events_fold_cpu(int cpu); #endif /* CONFIG_VM_EVENT_COUNTERS */ +#ifdef CONFIG_ZONE_DMA #define __count_zone_vm_events(item, zone, delta) \ __count_vm_events(item##_DMA + zone_idx(zone), delta) - +#else +#define __count_zone_vm_events(item, zone, delta) \ + __count_vm_events(item##_NORMAL + zone_idx(zone), delta) +#endif /* * Zone based page accounting with per cpu differentials. */ @@ -135,14 +145,16 @@ static inline unsigned long node_page_st struct zone *zones = NODE_DATA(node)->node_zones; return +#ifdef CONFIG_ZONE_DMA + zone_page_state(&zones[ZONE_DMA], item) + +#endif #ifdef CONFIG_ZONE_DMA32 zone_page_state(&zones[ZONE_DMA32], item) + #endif - zone_page_state(&zones[ZONE_NORMAL], item) + #ifdef CONFIG_HIGHMEM zone_page_state(&zones[ZONE_HIGHMEM], item) + #endif - zone_page_state(&zones[ZONE_DMA], item); + zone_page_state(&zones[ZONE_NORMAL], item); } extern void zone_statistics(struct zonelist *, struct zone *);