From: Christoph Lameter Make ZONE_HIGHMEM optional - ifdef out code and definitions related to CONFIG_HIGHMEM - __GFP_HIGHMEM falls back to normal allocations if there is no ZONE_HIGHMEM - GFP_ZONEMASK becomes 0x01 if there is no DMA32 and no HIGHMEM zone. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton --- include/linux/gfp.h | 6 ++++++ include/linux/mmzone.h | 19 +++++++++++++++++-- mm/page_alloc.c | 6 ++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff -puN include/linux/gfp.h~reduce-max_nr_zones-make-zone_highmem-optional include/linux/gfp.h --- a/include/linux/gfp.h~reduce-max_nr_zones-make-zone_highmem-optional +++ a/include/linux/gfp.h @@ -12,7 +12,13 @@ struct vm_area_struct; */ /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */ #define __GFP_DMA ((__force gfp_t)0x01u) + +#ifdef CONFIG_HIGHMEM #define __GFP_HIGHMEM ((__force gfp_t)0x02u) +#else +#define __GFP_HIGHMEM ((__force gfp_t)0x00) /* NORMAL is HIGHMEM */ +#endif + #ifndef CONFIG_ZONE_DMA32 #define __GFP_DMA32 ((__force gfp_t)0x01) /* ZONE_DMA is ZONE_DMA32 */ #elif BITS_PER_LONG < 64 diff -puN include/linux/mmzone.h~reduce-max_nr_zones-make-zone_highmem-optional include/linux/mmzone.h --- a/include/linux/mmzone.h~reduce-max_nr_zones-make-zone_highmem-optional +++ a/include/linux/mmzone.h @@ -122,6 +122,7 @@ enum zone_type { * transfers to all addressable memory. */ ZONE_NORMAL, +#ifdef CONFIG_HIGHMEM /* * A memory area that is only addressable by the kernel through * mapping portions into its own address space. This is for example @@ -131,11 +132,10 @@ enum zone_type { * access. */ ZONE_HIGHMEM, - +#endif MAX_NR_ZONES }; -#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ /* * When a memory allocation must conform to specific limitations (such @@ -166,8 +166,15 @@ enum zone_type { #ifdef CONFIG_ZONE_DMA32 #define GFP_ZONEMASK 0x07 +#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ #else +#ifdef CONFIG_HIGHMEM #define GFP_ZONEMASK 0x03 +#define ZONES_SHIFT 2 +#else +#define GFP_ZONEMASK 0x01 +#define ZONES_SHIFT 1 +#endif #endif struct zone { @@ -408,7 +415,11 @@ static inline int populated_zone(struct static inline int is_highmem_idx(enum zone_type idx) { +#ifdef CONFIG_HIGHMEM return (idx == ZONE_HIGHMEM); +#else + return 0; +#endif } static inline int is_normal_idx(enum zone_type idx) @@ -424,7 +435,11 @@ static inline int is_normal_idx(enum zon */ static inline int is_highmem(struct zone *zone) { +#ifdef CONFIG_HIGHMEM return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM; +#else + return 0; +#endif } static inline int is_normal(struct zone *zone) diff -puN mm/page_alloc.c~reduce-max_nr_zones-make-zone_highmem-optional mm/page_alloc.c --- a/mm/page_alloc.c~reduce-max_nr_zones-make-zone_highmem-optional +++ a/mm/page_alloc.c @@ -73,7 +73,9 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z #ifdef CONFIG_ZONE_DMA32 256, #endif +#ifdef CONFIG_HIGHMEM 32 +#endif }; EXPORT_SYMBOL(totalram_pages); @@ -91,7 +93,9 @@ static char *zone_names[MAX_NR_ZONES] = "DMA32", #endif "Normal", +#ifdef CONFIG_HIGHMEM "HighMem" +#endif }; int min_free_kbytes = 1024; @@ -1375,8 +1379,10 @@ static int __meminit build_zonelists_nod static inline int highest_zone(int zone_bits) { int res = ZONE_NORMAL; +#ifdef CONFIG_HIGHMEM if (zone_bits & (__force int)__GFP_HIGHMEM) res = ZONE_HIGHMEM; +#endif #ifdef CONFIG_ZONE_DMA32 if (zone_bits & (__force int)__GFP_DMA32) res = ZONE_DMA32; _