[patch -mm 2/2] mempolicy: use default_policy mode instead ofMPOL_DEFAULT

From: David Rientjes
Date: Fri Mar 07 2008 - 20:25:55 EST


default_policy is defined in mm/mempolicy.c as the default system policy:

struct mempolicy default_policy = {
.refcnt = ATOMIC_INIT(1),
.policy = MPOL_DEFAULT,
};

So instead of checking for comparisons against a mempolicy's mode to
MPOL_DEFAULT or falling back stricly to MPOL_DEFAULT throughout the code,
we should use the mode that is defined in this struct.

Cc: Paul Jackson <pj@xxxxxxx>
Cc: Christoph Lameter <clameter@xxxxxxx>
Cc: Lee Schermerhorn <Lee.Schermerhorn@xxxxxx>
Cc: Andi Kleen <ak@xxxxxxx>
Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
---
mm/mempolicy.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -185,7 +185,7 @@ static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,
return ERR_PTR(-EINVAL);
} else if (nodes && nodes_empty(*nodes))
return ERR_PTR(-EINVAL);
- if (mode == MPOL_DEFAULT)
+ if (mode == default_policy.policy)
return NULL;
policy = kmem_cache_alloc(policy_cache, GFP_KERNEL);
if (!policy)
@@ -1232,7 +1232,7 @@ static struct mempolicy * get_vma_policy(struct task_struct *task,
pol = vma->vm_ops->get_policy(vma, addr);
shared_pol = 1; /* if pol non-NULL, add ref below */
} else if (vma->vm_policy &&
- vma->vm_policy->policy != MPOL_DEFAULT)
+ vma->vm_policy->policy != default_policy.policy)
pol = vma->vm_policy;
}
if (!pol)
@@ -1588,7 +1588,7 @@ void __mpol_free(struct mempolicy *p)
{
if (!atomic_dec_and_test(&p->refcnt))
return;
- p->policy = MPOL_DEFAULT;
+ p->policy = default_policy.policy;
kmem_cache_free(policy_cache, p);
}

@@ -1752,10 +1752,10 @@ void mpol_shared_policy_init(struct shared_policy *info, unsigned short policy,
info->root = RB_ROOT;
spin_lock_init(&info->lock);

- if (policy != MPOL_DEFAULT) {
+ if (policy != default_policy.policy) {
struct mempolicy *newpol;

- /* Falls back to MPOL_DEFAULT on any error */
+ /* Falls back to default_policy on any error */
newpol = mpol_new(policy, flags, policy_nodes);
if (!IS_ERR(newpol)) {
/* Create pseudo-vma that contains just the policy */
@@ -1860,7 +1860,7 @@ void __init numa_policy_init(void)
/* Reset policy of current process to default */
void numa_default_policy(void)
{
- do_set_mempolicy(MPOL_DEFAULT, 0, NULL);
+ do_set_mempolicy(default_policy.policy, 0, NULL);
}

/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/