Currently the function to build a zonelist for a BIND policy has the side effect to set the policy_zone. This seems to be a bit strange. policy zone seems to not be initialized elsewhere and therefore 0. Do we police ZONE_DMA if no bind policy has been used yet? This patch moves the determination of the zone to apply policies to into the page allocator. We determine the zone while building the zonelist for nodes. Signed-off-by: Christoph Lameter Index: linux-2.6.15-rc5-mm1/mm/mempolicy.c =================================================================== --- linux-2.6.15-rc5-mm1.orig/mm/mempolicy.c 2005-12-06 17:22:59.000000000 -0800 +++ linux-2.6.15-rc5-mm1/mm/mempolicy.c 2005-12-06 19:21:06.000000000 -0800 @@ -105,7 +105,7 @@ static kmem_cache_t *sn_cache; /* Highest zone. An specific allocation for a zone below that is not policied. */ -static int policy_zone; +int policy_zone = ZONE_DMA; struct mempolicy default_policy = { .refcnt = ATOMIC_INIT(1), /* never free it */ @@ -143,17 +143,9 @@ static struct zonelist *bind_zonelist(no if (!zl) return NULL; num = 0; - for_each_node_mask(nd, *nodes) { - int k; - for (k = MAX_NR_ZONES-1; k >= 0; k--) { - struct zone *z = &NODE_DATA(nd)->node_zones[k]; - if (!populated_zone(z)) - continue; - zl->zones[num++] = z; - if (k > policy_zone) - policy_zone = k; - } - } + for_each_node_mask(nd, *nodes) + zl->zones[num++] = &NODE_DATA(nd)->node_zones[policy_zone]; + zl->zones[num] = NULL; return zl; } Index: linux-2.6.15-rc5-mm1/mm/page_alloc.c =================================================================== --- linux-2.6.15-rc5-mm1.orig/mm/page_alloc.c 2005-12-06 19:21:01.000000000 -0800 +++ linux-2.6.15-rc5-mm1/mm/page_alloc.c 2005-12-06 19:21:07.000000000 -0800 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "internal.h" @@ -1581,6 +1582,7 @@ static int __init build_zonelists_node(p BUG_ON(zone - pgdat->node_zones > ZONE_NORMAL); #endif zonelist->zones[j++] = zone; + check_highest_zone(k); } return j; } Index: linux-2.6.15-rc5-mm1/include/linux/mempolicy.h =================================================================== --- linux-2.6.15-rc5-mm1.orig/include/linux/mempolicy.h 2005-12-05 11:15:23.000000000 -0800 +++ linux-2.6.15-rc5-mm1/include/linux/mempolicy.h 2005-12-06 19:21:07.000000000 -0800 @@ -155,6 +155,14 @@ extern unsigned slab_node(struct mempoli int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags); +extern int policy_zone; + +static inline void check_highest_zone(int k) +{ + if (k > policy_zone) + policy_zone = k; +} + #else struct mempolicy {}; @@ -232,6 +240,9 @@ static inline int do_migrate_pages(struc return 0; } +static inline void check_highest_zone(int k) +{ +} #endif /* CONFIG_NUMA */ #endif /* __KERNEL__ */