From: Christoph Lameter We sometimes do comparisons like xx & (__GFP_x| __GFP_y)) == GFP_y This becomes a problem if GFP_y is redefined to be zero. Both __GFP_HIGHMEM (caused by me) and __GFP_DMA32 (was this way before) can become zero in order to cause a fall back to ZONE_NORMAL. We also have a GFP_MASK that is applied before indexing into the nodelists array. We can use that mask to avoid having both become zero and instead use the GFP_MASK to clear the respective bits before retrieving the zonelist. - Remove #ifdefs that cause __GFP_HIGHMEM or __GFP_DMA32 to become zero. - GFP_MASK works nicely to cause fall back to ZONE_NORMAL except if CONFIG_ZONE_DMA32 and !CONFIG_HIGHMEM are set. In that case the fallback to ZONE_NORMAL does not work. So add a special case to mmzone.h to define a special mask that switches off the highmem bit for this particular configuration. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton --- include/linux/gfp.h | 9 +-------- include/linux/mmzone.h | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff -puN include/linux/gfp.h~reduce-max_nr_zones-make-zone_highmem-optional-fix include/linux/gfp.h --- a/include/linux/gfp.h~reduce-max_nr_zones-make-zone_highmem-optional-fix +++ a/include/linux/gfp.h @@ -12,17 +12,10 @@ 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 +#if !defined(CONFIG_ZONE_DMA32) && BITS_PER_LONG >= 64 #define __GFP_DMA32 ((__force gfp_t)0x01) /* ZONE_DMA is ZONE_DMA32 */ -#elif BITS_PER_LONG < 64 -#define __GFP_DMA32 ((__force gfp_t)0x00) /* ZONE_NORMAL is ZONE_DMA32 */ #else #define __GFP_DMA32 ((__force gfp_t)0x04) /* Has own ZONE_DMA32 */ #endif diff -puN include/linux/mmzone.h~reduce-max_nr_zones-make-zone_highmem-optional-fix include/linux/mmzone.h --- a/include/linux/mmzone.h~reduce-max_nr_zones-make-zone_highmem-optional-fix +++ a/include/linux/mmzone.h @@ -163,18 +163,33 @@ enum zone_type { * * NOTE! Make sure this matches the zones in */ -#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */ #ifdef CONFIG_ZONE_DMA32 + +#ifdef CONFIG_HIGHMEM +#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */ #define GFP_ZONEMASK 0x07 -#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ +#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ +#else +#define GFP_ZONETYPES ((0x07 + 1) / 2 + 1) /* Loner */ +/* Mask __GFP_HIGHMEM */ +#define GFP_ZONEMASK 0x05 +#define ZONES_SHIFT 2 +#endif + #else #ifdef CONFIG_HIGHMEM + #define GFP_ZONEMASK 0x03 -#define ZONES_SHIFT 2 +#define ZONES_SHIFT 2 +#define GFP_ZONETYPES 3 + #else + #define GFP_ZONEMASK 0x01 #define ZONES_SHIFT 1 +#define GFP_ZONETYPES 2 + #endif #endif _