Fix up GFP_ZONEMASK for GFP_DMA32 usage

There was some confusion about the different zone usage, this should fix
up the resulting mess in the GFP zonemask handling.

The different zone usage is still confusing (it's very easy to mix up
the individual zone numbers with the GFP zone _list_ numbers), so we
might want to clean up some of this in the future, but in the meantime
this should fix the actual problems.

Acked-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

+11 -16
+7 -2
include/linux/gfp.h
··· 11 11 /* 12 12 * GFP bitmasks.. 13 13 */ 14 - /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */ 14 + /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */ 15 15 #define __GFP_DMA ((__force gfp_t)0x01u) 16 16 #define __GFP_HIGHMEM ((__force gfp_t)0x02u) 17 17 #ifdef CONFIG_DMA_IS_DMA32 ··· 74 74 #define GFP_DMA32 __GFP_DMA32 75 75 76 76 77 - #define gfp_zone(mask) ((__force int)((mask) & (__force gfp_t)GFP_ZONEMASK)) 77 + static inline int gfp_zone(gfp_t gfp) 78 + { 79 + int zone = GFP_ZONEMASK & (__force int) gfp; 80 + BUG_ON(zone >= GFP_ZONETYPES); 81 + return zone; 82 + } 78 83 79 84 /* 80 85 * There is only one page-allocator function, and two main namespaces to
+4 -14
include/linux/mmzone.h
··· 91 91 * will be a maximum of 4 (2 ** 2) zonelists, for 3 modifiers there will 92 92 * be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible 93 93 * combinations of zone modifiers in "zone modifier space". 94 + * 95 + * NOTE! Make sure this matches the zones in <linux/gfp.h> 94 96 */ 95 - #define GFP_ZONEMASK 0x03 96 - /* 97 - * As an optimisation any zone modifier bits which are only valid when 98 - * no other zone modifier bits are set (loners) should be placed in 99 - * the highest order bits of this field. This allows us to reduce the 100 - * extent of the zonelists thus saving space. For example in the case 101 - * of three zone modifier bits, we could require up to eight zonelists. 102 - * If the left most zone modifier is a "loner" then the highest valid 103 - * zonelist would be four allowing us to allocate only five zonelists. 104 - * Use the first form when the left most bit is not a "loner", otherwise 105 - * use the second. 106 - */ 107 - /* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */ 108 - #define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */ 97 + #define GFP_ZONEMASK 0x07 98 + #define GFP_ZONETYPES 5 109 99 110 100 /* 111 101 * On machines where it is needed (eg PCs) we divide physical memory