Re: [PATCH] mm: cleanup gfp_zone()

From: Andrew Morton
Date: Tue Sep 28 2010 - 17:33:18 EST


On Tue, 28 Sep 2010 21:23:44 +0900
Namhyung Kim <namhyung@xxxxxxxxx> wrote:

> Use Z[TB]_SHIFT() macro to calculate GFP_ZONE_TABLE and GFP_ZONE_BAD.
> This also removes lots of warnings from sparse like following:
>
> warning: restricted gfp_t degrades to integer
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
> ---
> include/linux/gfp.h | 43 ++++++++++++++++++++++++-------------------
> 1 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 975609c..cebfee1 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -185,15 +185,16 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
> #error ZONES_SHIFT too large to create GFP_ZONE_TABLE integer
> #endif
>
> +#define ZT_SHIFT(gfp) ((__force int) (gfp) * ZONES_SHIFT)
> #define GFP_ZONE_TABLE ( \
> - (ZONE_NORMAL << 0 * ZONES_SHIFT) \
> - | (OPT_ZONE_DMA << __GFP_DMA * ZONES_SHIFT) \
> - | (OPT_ZONE_HIGHMEM << __GFP_HIGHMEM * ZONES_SHIFT) \
> - | (OPT_ZONE_DMA32 << __GFP_DMA32 * ZONES_SHIFT) \
> - | (ZONE_NORMAL << __GFP_MOVABLE * ZONES_SHIFT) \
> - | (OPT_ZONE_DMA << (__GFP_MOVABLE | __GFP_DMA) * ZONES_SHIFT) \
> - | (ZONE_MOVABLE << (__GFP_MOVABLE | __GFP_HIGHMEM) * ZONES_SHIFT)\
> - | (OPT_ZONE_DMA32 << (__GFP_MOVABLE | __GFP_DMA32) * ZONES_SHIFT)\
> + (ZONE_NORMAL << ZT_SHIFT(0)) \
> + | (OPT_ZONE_DMA << ZT_SHIFT(__GFP_DMA)) \
> + | (OPT_ZONE_HIGHMEM << ZT_SHIFT(__GFP_HIGHMEM)) \
> + | (OPT_ZONE_DMA32 << ZT_SHIFT(__GFP_DMA32)) \
> + | (ZONE_NORMAL << ZT_SHIFT(__GFP_MOVABLE)) \
> + | (OPT_ZONE_DMA << ZT_SHIFT(__GFP_MOVABLE | __GFP_DMA)) \
> + | (ZONE_MOVABLE << ZT_SHIFT(__GFP_MOVABLE | __GFP_HIGHMEM)) \
> + | (OPT_ZONE_DMA32 << ZT_SHIFT(__GFP_MOVABLE | __GFP_DMA32)) \
> )

hm. I hope these sparse warnings are sufficiently useful to justify
all the gunk we're adding to support them.

Is it actually finding any bugs?
--
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/