highmem: CONFIG_HIGHMEM cleanup - Make sure that macros unconditionally return false if CONFIG_HIGHMEM is not defined. This will avoid generating code for highmem when the kernel is compiled without highmem support. - Define arrays of lowmem resources based on ZONE_NORMAL and not on MAX_NR_ZONES - Remove some uses of ZONE_HIGHMEM that are not necessary. Signed-off-by: Christoph Lameter Index: linux-2.6.17-mm3/include/linux/mmzone.h =================================================================== --- linux-2.6.17-mm3.orig/include/linux/mmzone.h 2006-06-28 12:48:49.250763069 -0700 +++ linux-2.6.17-mm3/include/linux/mmzone.h 2006-06-28 12:54:23.402967800 -0700 @@ -376,9 +376,14 @@ static inline int populated_zone(struct static inline int is_highmem_idx(int idx) { +#ifdef CONFIG_HIGHMEM return (idx == ZONE_HIGHMEM); +#else + return 0; +#endif } + static inline int is_normal_idx(int idx) { return (idx == ZONE_NORMAL); @@ -392,7 +397,11 @@ static inline int is_normal_idx(int idx) */ 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) @@ -415,7 +424,7 @@ struct ctl_table; struct file; int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); -extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1]; +extern int sysctl_lowmem_reserve_ratio[ZONE_NORMAL + 1]; int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int, struct file *, Index: linux-2.6.17-mm3/mm/page_alloc.c =================================================================== --- linux-2.6.17-mm3.orig/mm/page_alloc.c 2006-06-28 12:49:33.558572405 -0700 +++ linux-2.6.17-mm3/mm/page_alloc.c 2006-06-28 12:54:23.404920804 -0700 @@ -70,7 +70,7 @@ static void __free_pages_ok(struct page * TBD: should special case ZONE_DMA32 machines here - in those we normally * don't need any ZONE_NORMAL reservation */ -int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { 256, 256, 32 }; +int sysctl_lowmem_reserve_ratio[ZONE_NORMAL + 1] = { 256, 256, 32 }; EXPORT_SYMBOL(totalram_pages); @@ -1385,8 +1385,7 @@ static int __meminit build_zonelists_nod struct zonelist *zonelist, int nr_zones, int zone_type) { struct zone *zone; - - BUG_ON(zone_type > ZONE_HIGHMEM); + BUG_ON(zone_type >= MAX_NR_ZONES); do { zone = pgdat->node_zones + zone_type; @@ -1406,8 +1405,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 if (zone_bits & (__force int)__GFP_DMA32) res = ZONE_DMA32; if (zone_bits & (__force int)__GFP_DMA) @@ -2021,7 +2022,7 @@ static void __meminit free_area_init_cor if (zholes_size) realsize -= zholes_size[j]; - if (j < ZONE_HIGHMEM) + if (!is_highmem_idx(j)) nr_kernel_pages += realsize; nr_all_pages += realsize;