Re: [PATCH 04/19] Convert gfp_zone() to use a table of precalculatedvalues

From: Christoph Lameter
Date: Tue Feb 24 2009 - 11:53:57 EST


On Tue, 24 Feb 2009, Mel Gorman wrote:

> static inline enum zone_type gfp_zone(gfp_t flags)
> {
> -#ifdef CONFIG_ZONE_DMA
> - if (flags & __GFP_DMA)
> - return ZONE_DMA;
> -#endif
> -#ifdef CONFIG_ZONE_DMA32
> - if (flags & __GFP_DMA32)
> - return ZONE_DMA32;
> -#endif
> - if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
> - (__GFP_HIGHMEM | __GFP_MOVABLE))
> - return ZONE_MOVABLE;
> -#ifdef CONFIG_HIGHMEM
> - if (flags & __GFP_HIGHMEM)
> - return ZONE_HIGHMEM;
> -#endif
> - return ZONE_NORMAL;
> + return gfp_zone_table[flags & GFP_ZONEMASK];
> }

Aassume

GFP_DMA = 0x01
GFP_DMA32 = 0x02
GFP_MOVABLE = 0x04
GFP_HIGHMEM = 0x08

ZONE_NORMAL = 0
ZONE_DMA = 1
ZONE_DMA32 = 2
ZONE_MOVABLE = 3
ZONE_HIGHMEM = 4

then we could implement gfp_zone simply as:

static inline enum zone_type gfp_zone(gfp_t flags)
{
return ffs(flags & 0xf);
}

However, this would return ZONE_MOVABLE if only GFP_MOVABLE would be
set but not GFP_HIGHMEM.

If we could make sure that GFP_MOVABLE always includes GFP_HIGHMEM then
this would not be a problem.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/