]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/mpol: Add MPOL_MF_NOOP
authorLee Schermerhorn <lee.schermerhorn@hp.com>
Mon, 16 Jan 2012 13:43:29 +0000 (14:43 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 26 Sep 2012 09:48:33 +0000 (11:48 +0200)
This patch augments the MPOL_MF_LAZY feature by adding a "NOOP"
policy to mbind().  When the NOOP policy is used with the 'MOVE
and 'LAZY flags, mbind() [check_range()] will walk the specified
range and unmap eligible pages so that they will be migrated on
next touch.

This allows an application to prepare for a new phase of operation
where different regions of shared storage will be assigned to
worker threads, w/o changing policy.  Note that we could just use
"default" policy in this case.  However, this also allows an
application to request that pages be migrated, only if necessary,
to follow any arbitrary policy that might currently apply to a
range of pages, without knowing the policy, or without specifying
multiple mbind()s for ranges with different policies.

Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/mempolicy.h
mm/mempolicy.c

index 73683fb4f4470888ea28347c519e49ff38330c52..9fe1ab12cdeb37cb9ea16c1703c56a59b79d76e0 100644 (file)
@@ -21,6 +21,7 @@ enum {
        MPOL_BIND,
        MPOL_INTERLEAVE,
        MPOL_LOCAL,
+       MPOL_NOOP,              /* retain existing policy for range */
        MPOL_MAX,       /* always last member of enum */
 };
 
index 52c268b97b6ab4b8fa2337ab82ba9473c06f4db3..0de12e2f0f446a931d2ba4b4352f311a4a21bca5 100644 (file)
@@ -251,10 +251,10 @@ static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,
        pr_debug("setting mode %d flags %d nodes[0] %lx\n",
                 mode, flags, nodes ? nodes_addr(*nodes)[0] : -1);
 
-       if (mode == MPOL_DEFAULT) {
+       if (mode == MPOL_DEFAULT || mode == MPOL_NOOP) {
                if (nodes && !nodes_empty(*nodes))
                        return ERR_PTR(-EINVAL);
-               return NULL;    /* simply delete any existing policy */
+               return NULL;
        }
        VM_BUG_ON(!nodes);
 
@@ -1137,7 +1137,7 @@ static long do_mbind(unsigned long start, unsigned long len,
        if (start & ~PAGE_MASK)
                return -EINVAL;
 
-       if (mode == MPOL_DEFAULT)
+       if (mode == MPOL_DEFAULT || mode == MPOL_NOOP)
                flags &= ~MPOL_MF_STRICT;
 
        len = (len + PAGE_SIZE - 1) & PAGE_MASK;
@@ -1189,7 +1189,7 @@ static long do_mbind(unsigned long start, unsigned long len,
                          flags | MPOL_MF_INVERT, &pagelist);
 
        err = PTR_ERR(vma);     /* maybe ... */
-       if (!IS_ERR(vma))
+       if (!IS_ERR(vma) && mode != MPOL_NOOP)
                err = mbind_range(mm, start, end, new);
 
        if (!err) {