From: Christoph Lameter <clameter@sgi.com>
To: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org, ak@suse.de,
eric.whitney@hp.com, mel@skynet.ie
Subject: Re: [PATCH/RFC 4/4] Mem Policy: Fixup Fallback for Default Shmem Policy
Date: Fri, 12 Oct 2007 10:57:36 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0710121045380.8891@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <20071012154918.8157.26655.sendpatchset@localhost>
On Fri, 12 Oct 2007, Lee Schermerhorn wrote:
> 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.
I still think there must be a thinko here. The function seems to be
currently coded with the assumption that get_policy always returns a
policy. That policy may be the default policy??
If it returns NULL then the tasks policy is applied to shmem segment. I
though we wanted a consistent application of policies to shmem segments?
Now one task or another may determine placement.
I still have no idea what your warrant is for being sure that the object
continues to exist before increasing the policy refcount in
get_vma_policy()? What pins the shared policy before we get the refcount?
Some more concerns below:
> 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 get_vma_policy is called from the numa_maps handler then we have taken
a refcount on the task struct.
So this should be
int pol_needs_ref = 0;
>
> 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++;
Why do we need a ref here for a vma policy? The policy is pinned through
the ref to the task structure.
> + }
> }
> 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;
The mpol_get() here looks wrong. get_vma_policy determines the
current policy. The policy must already be pinned by increasing the
refcount or use in a certain task before get_vma_policy is ever called.
--
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 17:57 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 ` [PATCH/RFC 4/4] Mem Policy: Fixup Fallback for Default Shmem Policy Lee Schermerhorn
2007-10-12 17:57 ` Christoph Lameter [this message]
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=Pine.LNX.4.64.0710121045380.8891@schroedinger.engr.sgi.com \
--to=clameter@sgi.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=eric.whitney@hp.com \
--cc=lee.schermerhorn@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).