assume that the allocation flags is 0x421 which can be tranlate to:
__GFP_DMA | GFP_HIGH | GFP_REPEAT
which means allocate memory from ZONE_DMA, Will gfp_zone be able to get ZONE_DMA from gfp flags?
Let's continue:
#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
The GFP_ZONEMASK on my system would be:
GFP_ZONEMASK = 0x03
We have total three zones, so
ZONES_SHIFT = 0x02
GFP_ZONE_TABLE would be:
2 << 0x02 =33=100001
bit = (__GFP_DMA | __GFP_HIGH | __GFP_REPEAT ) & 0x03 = 0x01
static inline enum zone_type gfp_zone(gfp_t flags)
{
enum zone_type z;
int bit = flags & GFP_ZONEMASK;
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
((1 <<>> bit) & 1);
else {
#ifdef CONFIG_DEBUG_VM
BUG_ON((GFP_ZONE_BAD >> bit) & 1);
#endif
}
return z;
}
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & ((1 << ZONES_SHIFT) - 1)
= (100001 >> (0x01 * 0x02)) & (( 1 << 0x02 -1 )
= 1000 & 0011
= 0
= ZONE_DMA
No comments:
Post a Comment