• Christoph Lameter's avatar
    [PATCH] mempolicies: fix policy_zone check · 4e4785bc
    Christoph Lameter authored
    There is a check in zonelist_policy that compares pieces of the bitmap
    obtained from a gfp mask via GFP_ZONETYPES with a zone number in function
    The bitmap is an ORed mask of __GFP_DMA, __GFP_DMA32 and __GFP_HIGHMEM.
    The policy_zone is a zone number with the possible values of ZONE_DMA,
    ZONE_DMA32, ZONE_HIGHMEM and ZONE_NORMAL. These are two different domains
    of values.
    For some reason seemed to work before the zone reduction patchset (It
    definitely works on SGI boxes since we just have one zone and the check
    cannot fail).
    With the zone reduction patchset this check definitely fails on systems
    with two zones if the system actually has memory in both zones.
    This is because ZONE_NORMAL is selected using no __GFP flag at
    all and thus gfp_zone(gfpmask) == 0. ZONE_DMA is selected when __GFP_DMA
    is set. __GFP_DMA is 0x01.  So gfp_zone(gfpmask) == 1.
    policy_zone is set to ZONE_NORMAL (==1) if ZONE_NORMAL and ZONE_DMA are
    For ZONE_NORMAL gfp_zone(<no _GFP_DMA>) yields 0 which is <
    policy_zone(ZONE_NORMAL) and so policy is not applied to regular memory
    Instead gfp_zone(__GFP_DMA) == 1 which results in policy being applied
    to DMA allocations!
    What we realy want in that place is to establish the highest allowable
    zone for a given gfp_mask. If the highest zone is higher or equal to the
    policy_zone then memory policies need to be applied. We have such
    a highest_zone() function in page_alloc.c.
    So move the highest_zone() function from mm/page_alloc.c into
    include/linux/gfp.h.  On the way we simplify the function and use the new
    zone_type that was also introduced with the zone reduction patchset plus we
    also specify the right type for the gfp flags parameter.
    Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
    Signed-off-by: default avatarLee Schermerhorn <Lee.Schermerhorn@hp.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
gfp.h 6.07 KB