提交 4be38e35 编写于 作者: C Christoph Lameter 提交者: Linus Torvalds

[PATCH] mm: move determination of policy_zone into page allocator

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: NChristoph Lameter <clameter@sgi.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 1a93205b
...@@ -151,6 +151,14 @@ extern struct mempolicy default_policy; ...@@ -151,6 +151,14 @@ extern struct mempolicy default_policy;
extern struct zonelist *huge_zonelist(struct vm_area_struct *vma, extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
unsigned long addr); unsigned long addr);
extern int policy_zone;
static inline void check_highest_zone(int k)
{
if (k > policy_zone)
policy_zone = k;
}
#else #else
struct mempolicy {}; struct mempolicy {};
...@@ -221,6 +229,9 @@ static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma, ...@@ -221,6 +229,9 @@ static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma,
return NODE_DATA(0)->node_zonelists + gfp_zone(GFP_HIGHUSER); return NODE_DATA(0)->node_zonelists + gfp_zone(GFP_HIGHUSER);
} }
static inline void check_highest_zone(int k)
{
}
#endif /* CONFIG_NUMA */ #endif /* CONFIG_NUMA */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -93,7 +93,7 @@ static kmem_cache_t *sn_cache; ...@@ -93,7 +93,7 @@ static kmem_cache_t *sn_cache;
/* Highest zone. An specific allocation for a zone below that is not /* Highest zone. An specific allocation for a zone below that is not
policied. */ policied. */
static int policy_zone; int policy_zone = ZONE_DMA;
struct mempolicy default_policy = { struct mempolicy default_policy = {
.refcnt = ATOMIC_INIT(1), /* never free it */ .refcnt = ATOMIC_INIT(1), /* never free it */
...@@ -131,17 +131,8 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes) ...@@ -131,17 +131,8 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes)
if (!zl) if (!zl)
return NULL; return NULL;
num = 0; num = 0;
for_each_node_mask(nd, *nodes) { for_each_node_mask(nd, *nodes)
int k; zl->zones[num++] = &NODE_DATA(nd)->node_zones[policy_zone];
for (k = MAX_NR_ZONES-1; k >= 0; k--) {
struct zone *z = &NODE_DATA(nd)->node_zones[k];
if (!z->present_pages)
continue;
zl->zones[num++] = z;
if (k > policy_zone)
policy_zone = k;
}
}
zl->zones[num] = NULL; zl->zones[num] = NULL;
return zl; return zl;
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/memory_hotplug.h> #include <linux/memory_hotplug.h>
#include <linux/nodemask.h> #include <linux/nodemask.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/mempolicy.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include "internal.h" #include "internal.h"
...@@ -1470,6 +1471,7 @@ static int __init build_zonelists_node(pg_data_t *pgdat, ...@@ -1470,6 +1471,7 @@ static int __init build_zonelists_node(pg_data_t *pgdat,
BUG_ON(zone - pgdat->node_zones > ZONE_NORMAL); BUG_ON(zone - pgdat->node_zones > ZONE_NORMAL);
#endif #endif
zonelist->zones[j++] = zone; zonelist->zones[j++] = zone;
check_highest_zone(k);
} }
} }
return j; return j;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册