Commit ae4d8c16 authored by Lee Schermerhorn's avatar Lee Schermerhorn Committed by Linus Torvalds

mempolicy: fixup Fallback for Default Shmem Policy

get_vma_policy() is not handling fallback to task policy correctly when the
get_policy() vm_op returns NULL.  The NULL overwrites the 'pol' variable that
was holding the fallback task mempolicy.  So, it was falling back directly to
system default policy.

Fix get_vma_policy() to use only non-NULL policy returned from the vma
get_policy op.

shm_get_policy() was falling back to current task's mempolicy if the "backing
file system" [tmpfs vs hugetlbfs] does not support the get_policy vm_op and
the vma policy is null.  This is incorrect for show_numa_maps() which is
likely querying the numa_maps of some task other than current.  Remove this
fallback.
Signed-off-by: default avatarLee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f4e53d91
...@@ -274,8 +274,7 @@ static struct mempolicy *shm_get_policy(struct vm_area_struct *vma, ...@@ -274,8 +274,7 @@ static struct mempolicy *shm_get_policy(struct vm_area_struct *vma,
else if (vma->vm_policy) { else if (vma->vm_policy) {
pol = vma->vm_policy; pol = vma->vm_policy;
mpol_get(pol); /* get_vma_policy() expects this */ mpol_get(pol); /* get_vma_policy() expects this */
} else }
pol = current->mempolicy;
return pol; return pol;
} }
#endif #endif
......
...@@ -1262,7 +1262,7 @@ asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len, ...@@ -1262,7 +1262,7 @@ asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
* @task != current]. It is the caller's responsibility to * @task != current]. It is the caller's responsibility to
* free the reference in these cases. * free the reference in these cases.
*/ */
static struct mempolicy * get_vma_policy(struct task_struct *task, static struct mempolicy *get_vma_policy(struct task_struct *task,
struct vm_area_struct *vma, unsigned long addr) struct vm_area_struct *vma, unsigned long addr)
{ {
struct mempolicy *pol = task->mempolicy; struct mempolicy *pol = task->mempolicy;
...@@ -1270,7 +1270,10 @@ static struct mempolicy * get_vma_policy(struct task_struct *task, ...@@ -1270,7 +1270,10 @@ static struct mempolicy * get_vma_policy(struct task_struct *task,
if (vma) { if (vma) {
if (vma->vm_ops && vma->vm_ops->get_policy) { if (vma->vm_ops && vma->vm_ops->get_policy) {
pol = vma->vm_ops->get_policy(vma, addr); struct mempolicy *vpol = vma->vm_ops->get_policy(vma,
addr);
if (vpol)
pol = vpol;
shared_pol = 1; /* if pol non-NULL, add ref below */ shared_pol = 1; /* if pol non-NULL, add ref below */
} else if (vma->vm_policy && } else if (vma->vm_policy &&
vma->vm_policy->policy != MPOL_DEFAULT) vma->vm_policy->policy != MPOL_DEFAULT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment