* [PATCH] mm: cleanup gfp_zone()
@ 2010-09-28 12:23 Namhyung Kim
2010-09-28 21:32 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2010-09-28 12:23 UTC (permalink / raw)
To: Andrew Morton; +Cc: Al Viro, linux-mm, linux-kernel
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@gmail.com>
---
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)) \
)
/*
@@ -202,24 +203,25 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
* entry starting with bit 0. Bit is set if the combination is not
* allowed.
*/
+#define ZB_SHIFT(gfp) ((__force int) (gfp))
#define GFP_ZONE_BAD ( \
- 1 << (__GFP_DMA | __GFP_HIGHMEM) \
- | 1 << (__GFP_DMA | __GFP_DMA32) \
- | 1 << (__GFP_DMA32 | __GFP_HIGHMEM) \
- | 1 << (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM) \
- | 1 << (__GFP_MOVABLE | __GFP_HIGHMEM | __GFP_DMA) \
- | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA) \
- | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_HIGHMEM) \
- | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA | __GFP_HIGHMEM)\
+ 1 << ZB_SHIFT(__GFP_DMA | __GFP_HIGHMEM) \
+ | 1 << ZB_SHIFT(__GFP_DMA | __GFP_DMA32) \
+ | 1 << ZB_SHIFT(__GFP_DMA32 | __GFP_HIGHMEM) \
+ | 1 << ZB_SHIFT(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM) \
+ | 1 << ZB_SHIFT(__GFP_MOVABLE | __GFP_HIGHMEM | __GFP_DMA) \
+ | 1 << ZB_SHIFT(__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA) \
+ | 1 << ZB_SHIFT(__GFP_MOVABLE | __GFP_DMA32 | __GFP_HIGHMEM) \
+ | 1 << ZB_SHIFT(__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA | \
+ __GFP_HIGHMEM) \
)
static inline enum zone_type gfp_zone(gfp_t flags)
{
enum zone_type z;
- int bit = flags & GFP_ZONEMASK;
+ int bit = (__force int) (flags & GFP_ZONEMASK);
- z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
- ((1 << ZONES_SHIFT) - 1);
+ z = (GFP_ZONE_TABLE >> ZT_SHIFT(bit)) & ((1 << ZONES_SHIFT) - 1);
if (__builtin_constant_p(bit))
MAYBE_BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
@@ -231,6 +233,9 @@ static inline enum zone_type gfp_zone(gfp_t flags)
return z;
}
+#undef ZT_SHIFT
+#undef ZB_SHIFT
+
/*
* There is only one page-allocator function, and two main namespaces to
* it. The alloc_page*() variants return 'struct page *' and as such
--
1.7.2.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: cleanup gfp_zone()
2010-09-28 12:23 [PATCH] mm: cleanup gfp_zone() Namhyung Kim
@ 2010-09-28 21:32 ` Andrew Morton
2010-09-28 21:41 ` Al Viro
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2010-09-28 21:32 UTC (permalink / raw)
To: Namhyung Kim; +Cc: Al Viro, linux-mm, linux-kernel
On Tue, 28 Sep 2010 21:23:44 +0900
Namhyung Kim <namhyung@gmail.com> 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@gmail.com>
> ---
> 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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: cleanup gfp_zone()
2010-09-28 21:32 ` Andrew Morton
@ 2010-09-28 21:41 ` Al Viro
2010-09-28 21:45 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: Al Viro @ 2010-09-28 21:41 UTC (permalink / raw)
To: Andrew Morton; +Cc: Namhyung Kim, linux-mm, linux-kernel
On Tue, Sep 28, 2010 at 02:32:39PM -0700, Andrew Morton wrote:
> > +#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?
FWIW, bitwise or done in the right-hand argumet of shift looks ugly as hell;
what the hell is that code _doing_?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: cleanup gfp_zone()
2010-09-28 21:41 ` Al Viro
@ 2010-09-28 21:45 ` Andrew Morton
2010-09-28 22:15 ` Al Viro
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2010-09-28 21:45 UTC (permalink / raw)
To: Al Viro; +Cc: Namhyung Kim, linux-mm, linux-kernel
On Tue, 28 Sep 2010 22:41:42 +0100
Al Viro <viro@ZenIV.linux.org.uk> wrote:
> On Tue, Sep 28, 2010 at 02:32:39PM -0700, Andrew Morton wrote:
> > > +#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?
>
> FWIW, bitwise or done in the right-hand argumet of shift looks ugly as hell;
> what the hell is that code _doing_?
There's a nice fat comment a few lines up...
/*
* GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
* zone to use given the lowest 4 bits of gfp_t. Entries are ZONE_SHIFT long
* and there are 16 of them to cover all possible combinations of
* __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
*
* The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
* But GFP_MOVABLE is not only a zone specifier but also an allocation
* policy. Therefore __GFP_MOVABLE plus another zone selector is valid.
* Only 1 bit of the lowest 3 bits (DMA,DMA32,HIGHMEM) can be set to "1".
*
* bit result
* =================
* 0x0 => NORMAL
* 0x1 => DMA or NORMAL
* 0x2 => HIGHMEM or NORMAL
* 0x3 => BAD (DMA+HIGHMEM)
* 0x4 => DMA32 or DMA or NORMAL
* 0x5 => BAD (DMA+DMA32)
* 0x6 => BAD (HIGHMEM+DMA32)
* 0x7 => BAD (HIGHMEM+DMA32+DMA)
* 0x8 => NORMAL (MOVABLE+0)
* 0x9 => DMA or NORMAL (MOVABLE+DMA)
* 0xa => MOVABLE (Movable is valid only if HIGHMEM is set too)
* 0xb => BAD (MOVABLE+HIGHMEM+DMA)
* 0xc => DMA32 (MOVABLE+HIGHMEM+DMA32)
* 0xd => BAD (MOVABLE+DMA32+DMA)
* 0xe => BAD (MOVABLE+DMA32+HIGHMEM)
* 0xf => BAD (MOVABLE+DMA32+HIGHMEM+DMA)
*
* ZONES_SHIFT must be <= 2 on 32 bit platforms.
*/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: cleanup gfp_zone()
2010-09-28 21:45 ` Andrew Morton
@ 2010-09-28 22:15 ` Al Viro
2010-09-29 7:06 ` [PATCH v2] mm: fix sparse warnings on GFP_ZONE_TABLE/BAD Namhyung Kim
0 siblings, 1 reply; 6+ messages in thread
From: Al Viro @ 2010-09-28 22:15 UTC (permalink / raw)
To: Andrew Morton; +Cc: Namhyung Kim, linux-mm, linux-kernel
On Tue, Sep 28, 2010 at 02:45:18PM -0700, Andrew Morton wrote:
> On Tue, 28 Sep 2010 22:41:42 +0100
> > > 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?
> >
> > FWIW, bitwise or done in the right-hand argumet of shift looks ugly as hell;
> > what the hell is that code _doing_?
>
> There's a nice fat comment a few lines up...
[snip]
Egads... IMO the cleanest way to deal with that is to add integer
constants, not to be used anywhere else (e.g. ___GFP_DMA, with
#define __GFP_DMA ((__force gfp_t)___GFP_DMA) and use them in that
horror.
As for the gfp_t warnings - yes, they'd caught a bunch of bugs at
some point; considering the bitrot rates... might be worth rechecking.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] mm: fix sparse warnings on GFP_ZONE_TABLE/BAD
2010-09-28 22:15 ` Al Viro
@ 2010-09-29 7:06 ` Namhyung Kim
0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2010-09-29 7:06 UTC (permalink / raw)
To: Al Viro; +Cc: Andrew Morton, linux-mm, linux-kernel
Introduce ___GFP_* masks in order for gfp_t not to mixed with
plain integers which causes a lot of warnings like following:
warning: restricted gfp_t degrades to integer
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
include/linux/gfp.h | 105 ++++++++++++++++++++++++++++++--------------------
1 files changed, 63 insertions(+), 42 deletions(-)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 975609c..e8713d5 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -9,6 +9,32 @@
struct vm_area_struct;
+/* Plain integer GFP bitmasks. Do not use this directly. */
+#define ___GFP_DMA 0x01u
+#define ___GFP_HIGHMEM 0x02u
+#define ___GFP_DMA32 0x04u
+#define ___GFP_MOVABLE 0x08u
+#define ___GFP_WAIT 0x10u
+#define ___GFP_HIGH 0x20u
+#define ___GFP_IO 0x40u
+#define ___GFP_FS 0x80u
+#define ___GFP_COLD 0x100u
+#define ___GFP_NOWARN 0x200u
+#define ___GFP_REPEAT 0x400u
+#define ___GFP_NOFAIL 0x800u
+#define ___GFP_NORETRY 0x1000u
+#define ___GFP_COMP 0x4000u
+#define ___GFP_ZERO 0x8000u
+#define ___GFP_NOMEMALLOC 0x10000u
+#define ___GFP_HARDWALL 0x20000u
+#define ___GFP_THISNODE 0x40000u
+#define ___GFP_RECLAIMABLE 0x80000u
+#ifdef CONFIG_KMEMCHECK
+#define ___GFP_NOTRACK 0x200000u
+#else
+#define ___GFP_NOTRACK 0
+#endif
+
/*
* GFP bitmasks..
*
@@ -18,10 +44,10 @@ struct vm_area_struct;
* without the underscores and use them consistently. The definitions here may
* be used in bit comparisons.
*/
-#define __GFP_DMA ((__force gfp_t)0x01u)
-#define __GFP_HIGHMEM ((__force gfp_t)0x02u)
-#define __GFP_DMA32 ((__force gfp_t)0x04u)
-#define __GFP_MOVABLE ((__force gfp_t)0x08u) /* Page is movable */
+#define __GFP_DMA ((__force gfp_t)___GFP_DMA)
+#define __GFP_HIGHMEM ((__force gfp_t)___GFP_HIGHMEM)
+#define __GFP_DMA32 ((__force gfp_t)___GFP_DMA32)
+#define __GFP_MOVABLE ((__force gfp_t)___GFP_MOVABLE) /* Page is movable */
#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
/*
* Action modifiers - doesn't change the zoning
@@ -38,27 +64,22 @@ struct vm_area_struct;
* __GFP_MOVABLE: Flag that this page will be movable by the page migration
* mechanism or reclaimed
*/
-#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */
-#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */
-#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */
-#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */
-#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */
-#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */
-#define __GFP_REPEAT ((__force gfp_t)0x400u) /* See above */
-#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* See above */
-#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* See above */
-#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */
-#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */
-#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
-#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */
-#define __GFP_THISNODE ((__force gfp_t)0x40000u)/* No fallback, no policies */
-#define __GFP_RECLAIMABLE ((__force gfp_t)0x80000u) /* Page is reclaimable */
-
-#ifdef CONFIG_KMEMCHECK
-#define __GFP_NOTRACK ((__force gfp_t)0x200000u) /* Don't track with kmemcheck */
-#else
-#define __GFP_NOTRACK ((__force gfp_t)0)
-#endif
+#define __GFP_WAIT ((__force gfp_t)___GFP_WAIT) /* Can wait and reschedule? */
+#define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) /* Should access emergency pools? */
+#define __GFP_IO ((__force gfp_t)___GFP_IO) /* Can start physical IO? */
+#define __GFP_FS ((__force gfp_t)___GFP_FS) /* Can call down to low-level FS? */
+#define __GFP_COLD ((__force gfp_t)___GFP_COLD) /* Cache-cold page required */
+#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) /* Suppress page allocation failure warning */
+#define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */
+#define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */
+#define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */
+#define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */
+#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */
+#define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves */
+#define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */
+#define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */
+#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */
+#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */
/*
* This may seem redundant, but it's a way of annotating false positives vs.
@@ -186,14 +207,14 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
#endif
#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 << 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) \
)
/*
@@ -203,20 +224,20 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
* allowed.
*/
#define GFP_ZONE_BAD ( \
- 1 << (__GFP_DMA | __GFP_HIGHMEM) \
- | 1 << (__GFP_DMA | __GFP_DMA32) \
- | 1 << (__GFP_DMA32 | __GFP_HIGHMEM) \
- | 1 << (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM) \
- | 1 << (__GFP_MOVABLE | __GFP_HIGHMEM | __GFP_DMA) \
- | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA) \
- | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_HIGHMEM) \
- | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA | __GFP_HIGHMEM)\
+ 1 << (___GFP_DMA | ___GFP_HIGHMEM) \
+ | 1 << (___GFP_DMA | ___GFP_DMA32) \
+ | 1 << (___GFP_DMA32 | ___GFP_HIGHMEM) \
+ | 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM) \
+ | 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA) \
+ | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA) \
+ | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \
+ | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \
)
static inline enum zone_type gfp_zone(gfp_t flags)
{
enum zone_type z;
- int bit = flags & GFP_ZONEMASK;
+ int bit = (__force int) (flags & GFP_ZONEMASK);
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
((1 << ZONES_SHIFT) - 1);
--
1.7.2.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-09-29 7:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-28 12:23 [PATCH] mm: cleanup gfp_zone() Namhyung Kim
2010-09-28 21:32 ` Andrew Morton
2010-09-28 21:41 ` Al Viro
2010-09-28 21:45 ` Andrew Morton
2010-09-28 22:15 ` Al Viro
2010-09-29 7:06 ` [PATCH v2] mm: fix sparse warnings on GFP_ZONE_TABLE/BAD Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).