linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Ken Chen <kenchen@google.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org, clameter@sgi.com
Subject: Re: [patch] check cpuset mems_allowed for sys_mbind
Date: Wed, 9 May 2007 16:48:59 -0700	[thread overview]
Message-ID: <20070509164859.15dd347b.pj@sgi.com> (raw)
In-Reply-To: <b040c32a0705091611mb35258ap334426e42d33372c@mail.gmail.com>

Ken wrote:
> I wonder why we don't check cpuset's mems_allowed node mask in the
> sys_mbind() path?

Looking back through the version history of mm/mempolicy.c, I see that
we used to check the cpuset (by calling contextualize_policy), but then
with the following patch (Christoph added to CC list above), this was
changed.

=========================== begin ===========================
Subject: - remove-policy-contextualization-from-mbind.patch removed from -mm tree
To: clameter@engr.sgi.com, ak@muc.de, clameter@sgi.com,
   mm-commits@vger.kernel.org
From: akpm@osdl.org
Date:   Sun, 30 Oct 2005 00:27:40 -0700


The patch titled

     Remove policy contextualization from mbind

has been removed from the -mm tree.  Its filename is

     remove-policy-contextualization-from-mbind.patch

This patch was probably dropped from -mm because
it has already been merged into a subsystem tree
or into Linus's tree


From: Christoph Lameter <clameter@engr.sgi.com>

Policy contextualization is only useful for task based policies and not for
vma based policies.  It may be useful to define allowed nodes that are not
accessible from this thread because other threads may have access to these
nodes.  Without this patch strange memory policy situations may cause an
application to fail with out of memory.

Example:

Let's say we have two threads A and B that share the same address space and
a huge array computational array X.

Thread A is restricted by its cpuset to nodes 0 and 1 and thread B is
restricted by its cpuset to nodes 2 and 3.

Thread A now wants to restrict allocations to the first node and thus
applies a BIND policy on X to node 0 and 2.  The cpuset limits this to node
0.  Thus pages for X must be allocated on node 0 now.

Thread B now touches a page that has never been used in X and faults in a
page.  According to the BIND policy of the vma for X the page must be
allocated on page 0.  However, the cpuset of B does not allow allocation on
0 and 1.  Now the application fails in alloc_pages with out of memory.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 mm/mempolicy.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff -puN mm/mempolicy.c~remove-policy-contextualization-from-mbind mm/mempolicy.c
--- devel/mm/mempolicy.c~remove-policy-contextualization-from-mbind     2005-10-29 17:43:43.000000000 -0700
+++ devel-akpm/mm/mempolicy.c   2005-10-29 17:43:43.000000000 -0700
@@ -370,7 +370,7 @@ long do_mbind(unsigned long start, unsig
                return -EINVAL;
        if (end == start)
                return 0;
-       if (contextualize_policy(mode, nmask))
+       if (mpol_check_policy(mode, nmask))
                return -EINVAL;
        new = mpol_new(mode, nmask);
        if (IS_ERR(new))
_

Patches currently in -mm which might be from clameter@engr.sgi.com are

increase-maximum-kmalloc-size-to-256k.patch
use-alloc_percpu-to-allocate-workqueues-locally.patch
============================ end ============================

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.925.600.0401

--
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>

  reply	other threads:[~2007-05-09 23:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-09 23:11 Ken Chen
2007-05-09 23:48 ` Paul Jackson [this message]
2007-05-10  0:47   ` Ken Chen
2007-05-10  0:55     ` Christoph Lameter
2007-05-10  1:26       ` Ken Chen
2007-05-10  1:44         ` Christoph Lameter
2007-05-10 18:32       ` Ken Chen
2007-05-10 18:41         ` Christoph Lameter
2007-05-10 19:30           ` Ken Chen

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=20070509164859.15dd347b.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=kenchen@google.com \
    --cc=linux-mm@kvack.org \
    /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