From: Lee Schermerhorn <lee.schermerhorn@hp.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, ak@suse.de, eric.whitney@hp.com,
clameter@sgi.com, mel@skynet.ie
Subject: [PATCH/RFC 4/4] Mem Policy: Fixup Fallback for Default Shmem Policy
Date: Fri, 12 Oct 2007 11:49:18 -0400 [thread overview]
Message-ID: <20071012154918.8157.26655.sendpatchset@localhost> (raw)
In-Reply-To: <20071012154854.8157.51441.sendpatchset@localhost>
PATCH 4/4 Mempolicy: Fixup Fallback for Default Shmem Policy
Against: 2.6.23-rc8-mm2
Separated from previous multi-issue patch 2/2
get_vma_policy() was 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 and indicate that this policy does not need
another ref count.
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
mm/mempolicy.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
Index: Linux/mm/mempolicy.c
===================================================================
--- Linux.orig/mm/mempolicy.c 2007-10-12 10:50:05.000000000 -0400
+++ Linux/mm/mempolicy.c 2007-10-12 10:52:46.000000000 -0400
@@ -1112,19 +1112,25 @@ static struct mempolicy * get_vma_policy
struct vm_area_struct *vma, unsigned long addr)
{
struct mempolicy *pol = task->mempolicy;
- int shared_pol = 0;
+ int pol_needs_ref = (task != current);
if (vma) {
if (vma->vm_ops && vma->vm_ops->get_policy) {
- pol = vma->vm_ops->get_policy(vma, addr);
- shared_pol = 1; /* if pol non-NULL, add ref below */
+ struct mempolicy *vpol = vma->vm_ops->get_policy(vma,
+ addr);
+ if (vpol) {
+ pol = vpol;
+ pol_needs_ref = 0; /* get_policy() added ref */
+ }
} else if (vma->vm_policy &&
- vma->vm_policy->policy != MPOL_DEFAULT)
+ vma->vm_policy->policy != MPOL_DEFAULT) {
pol = vma->vm_policy;
+ pol_needs_ref++;
+ }
}
if (!pol)
pol = &default_policy;
- else if (!shared_pol && pol != current->mempolicy)
+ else if (pol_needs_ref)
mpol_get(pol); /* vma or other task's policy */
return pol;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-10-12 15:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 15:48 [PATCH/RFC 0/4] More Mempolicy Reference Counting Fixes Lee Schermerhorn
2007-10-12 15:49 ` [PATCH/RFC 1/4] Mem Policy: fix mempolicy usage in pci driver Lee Schermerhorn
2007-10-12 17:29 ` Christoph Lameter
2007-10-12 15:49 ` [PATCH/RFC 2/4] Mem Policy: Fixup Shm and Interleave Policy Reference Counting Lee Schermerhorn
2007-10-12 17:30 ` Christoph Lameter
2007-10-12 15:49 ` [PATCH/RFC 3/4] Mem Policy: Fixup " Lee Schermerhorn
2007-10-12 17:33 ` Christoph Lameter
2007-10-12 15:49 ` Lee Schermerhorn [this message]
2007-10-12 17:57 ` [PATCH/RFC 4/4] Mem Policy: Fixup Fallback for Default Shmem Policy Christoph Lameter
2007-10-15 19:34 ` Christoph Lameter
2007-10-23 16:15 ` Lee Schermerhorn
2007-10-23 16:23 ` Christoph Lameter
2007-10-23 17:32 ` Lee Schermerhorn
2007-10-24 13:09 ` Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071012154918.8157.26655.sendpatchset@localhost \
--to=lee.schermerhorn@hp.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=eric.whitney@hp.com \
--cc=linux-mm@kvack.org \
--cc=mel@skynet.ie \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.