Skip to content

Commit

Permalink
Fix up GFP_ZONEMASK for GFP_DMA32 usage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds committed Nov 23, 2005
1 parent 4b4a27d commit ac3461a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
9 changes: 7 additions & 2 deletions include/linux/gfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct vm_area_struct;
/*
* GFP bitmasks..
*/
/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */
/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */
#define __GFP_DMA ((__force gfp_t)0x01u)
#define __GFP_HIGHMEM ((__force gfp_t)0x02u)
#ifdef CONFIG_DMA_IS_DMA32
Expand Down Expand Up @@ -74,7 +74,12 @@ struct vm_area_struct;
#define GFP_DMA32 __GFP_DMA32


#define gfp_zone(mask) ((__force int)((mask) & (__force gfp_t)GFP_ZONEMASK))
static inline int gfp_zone(gfp_t gfp)
{
int zone = GFP_ZONEMASK & (__force int) gfp;
BUG_ON(zone >= GFP_ZONETYPES);
return zone;
}

/*
* There is only one page-allocator function, and two main namespaces to
Expand Down
18 changes: 4 additions & 14 deletions include/linux/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,11 @@ struct per_cpu_pageset {
* will be a maximum of 4 (2 ** 2) zonelists, for 3 modifiers there will
* be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible
* combinations of zone modifiers in "zone modifier space".
*
* NOTE! Make sure this matches the zones in <linux/gfp.h>
*/
#define GFP_ZONEMASK 0x03
/*
* As an optimisation any zone modifier bits which are only valid when
* no other zone modifier bits are set (loners) should be placed in
* the highest order bits of this field. This allows us to reduce the
* extent of the zonelists thus saving space. For example in the case
* of three zone modifier bits, we could require up to eight zonelists.
* If the left most zone modifier is a "loner" then the highest valid
* zonelist would be four allowing us to allocate only five zonelists.
* Use the first form when the left most bit is not a "loner", otherwise
* use the second.
*/
/* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */
#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */
#define GFP_ZONEMASK 0x07
#define GFP_ZONETYPES 5

/*
* On machines where it is needed (eg PCs) we divide physical memory
Expand Down

0 comments on commit ac3461a

Please sign in to comment.