zone gfp_flags generate from ZONE_ constants
Subsystems (4)
PATCH 1/1 zone gfp_flags generate from ZONE_ constants
zone gfp_flags generate from ZONE_ constants
Change the allocation of the __GFP_zone style zone modifiers so that they are generated from the values of the ZONE_zone definitions. Note that when no zone modifiers are specified select the default zone, typically ZONE_NORMAL.
--- gfp.h | 22 ++++++++++++++++------ mmzone.h | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-)
include/linux/gfp.h +16 -6
@@ -11,15 +11,25 @@ struct vm_area_struct;/* * GFP bitmasks.. */ -/* 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) + +/* +* Generate the zone modifier bit. Zone ZONE_DEFAULT doesn't require a bit +* as the absence of all zone modifiers implies this zone. Renormalise the +* zone number such that ZONE_DEFAULT is at the bottom and discard it. +* These must fit within the bitmask GFP_ZONEMASK defined in linux/mmzone.h. +*/ +#define __ZONE_BIT (x) (((x) ^ ZONE_DEFAULT) - 1) +#define ZONE_MODIFIER (x) ((__force gfp_t)(((x) == ZONE_DEFAULT)? (0) : \ + 1UL << __ZONE_BIT(x))) + +#define __GFP_DMA ZONE_MODIFIER(ZONE_DMA) +#define __GFP_HIGHMEM ZONE_MODIFIER(ZONE_HIGHMEM)#ifdef CONFIG_DMA_IS_DMA32 -#define __GFP_DMA32 ((__force gfp_t)0x01)/* ZONE_DMA is ZONE_DMA32 */ +#define __GFP_DMA32 ZONE_MODIFIER(ZONE_DMA)/* ZONE_DMA is ZONE_DMA32 */ #elif BITS_PER_LONG <64 -#define __GFP_DMA32 ((__force gfp_t)0x00)/* ZONE_NORMAL is ZONE_DMA32 */ +#define __GFP_DMA32 ZONE_MODIFIER(ZONE_NORMAL)/* ZONE_NORMAL is ZONE_DMA32 */ #else -#define __GFP_DMA32 ((__force gfp_t)0x04)/* Has own ZONE_DMA32 */ +#define __GFP_DMA32 ZONE_MODIFIER(ZONE_DMA32)/* Has own ZONE_DMA32 */ #endif /*
include/linux/mmzone.h +2 -0
@@ -77,6 +77,8 @@ struct per_cpu_pageset {#define MAX_NR_ZONES 4/* Sync this with ZONES_SHIFT */ #define ZONES_SHIFT 2/* ceil(log2(MAX_NR_ZONES)) */ +/* Select the zone to use when no __GFP flags are selected. */ +#define ZONE_DEFAULT ZONE_NORMAL/* * When a memory allocation must conform to specific limitations (such
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 15 lines · Andy Whitcroft
+/*
+ * Generate the zone modifier bit. ZoneZONE_DEFAULTdoesn't require a bit
+ * as the absence of all zone modifiers implies this zone. Renormalise the
+ * zone number such thatZONE_DEFAULTis at the bottom and discard it.
+ * These must fit within the bitmaskGFP_ZONEMASKdefined inlinux/mmzone.h.
+ */
+#define__ZONE_BIT(x)(((x) ^ZONE_DEFAULT) - 1)
+#defineZONE_MODIFIER(x)((__forcegfp_t)(((x) ==ZONE_DEFAULT)? (0) : \
+ 1UL <<__ZONE_BIT(x)))
+
+#define__GFP_DMAZONE_MODIFIER(ZONE_DMA)
+#define__GFP_HIGHMEMZONE_MODIFIER(ZONE_HIGHMEM)
#ifdefCONFIG_DMA_IS_DMA32
-#define__GFP_DMA32((__forcegfp_t)0x01) /*ZONE_DMAisZONE_DMA32*/
Quoted 8 lines
+#define
__GFP_DMA32ZONE_MODIFIER(ZONE_DMA)/*ZONE_DMAisZONE_DMA32*/
#elifBITS_PER_LONG< 64
-#define__GFP_DMA32((__forcegfp_t)0x00) /*ZONE_NORMALisZONE_DMA32*/
+#define__GFP_DMA32ZONE_MODIFIER(ZONE_NORMAL)/*ZONE_NORMALisZONE_DMA32*/
#else
-#define__GFP_DMA32((__forcegfp_t)0x04) /* Has ownZONE_DMA32*/
+#define__GFP_DMA32ZONE_MODIFIER(ZONE_DMA32)/* Has ownZONE_DMA32*/
#endif
eek. We often look at the hex value of gfp flags in debug output to work out what sort of allocation is being attempted.
I guess we could print out the values of these things at boot time..
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>