Commit d3a71033 authored by Lee Schermerhorn's avatar Lee Schermerhorn Committed by Mel Gorman

mm: mempolicy: Add MPOL_NOOP

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() will map the pages PROT_NONE so that they will be
migrated on the 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.

[ Bug in early version of mpol_parse_str() reported by Fengguang Wu. ]
Bug-Reported-by: default avatarReported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarLee Schermerhorn <lee.schermerhorn@hp.com>
Reviewed-by: default avatarRik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
parent 479e2802
...@@ -21,6 +21,7 @@ enum { ...@@ -21,6 +21,7 @@ enum {
MPOL_BIND, MPOL_BIND,
MPOL_INTERLEAVE, MPOL_INTERLEAVE,
MPOL_LOCAL, MPOL_LOCAL,
MPOL_NOOP, /* retain existing policy for range */
MPOL_MAX, /* always last member of enum */ MPOL_MAX, /* always last member of enum */
}; };
......
...@@ -251,10 +251,10 @@ static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags, ...@@ -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", pr_debug("setting mode %d flags %d nodes[0] %lx\n",
mode, flags, nodes ? nodes_addr(*nodes)[0] : -1); mode, flags, nodes ? nodes_addr(*nodes)[0] : -1);
if (mode == MPOL_DEFAULT) { if (mode == MPOL_DEFAULT || mode == MPOL_NOOP) {
if (nodes && !nodes_empty(*nodes)) if (nodes && !nodes_empty(*nodes))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
return NULL; /* simply delete any existing policy */ return NULL;
} }
VM_BUG_ON(!nodes); VM_BUG_ON(!nodes);
...@@ -1147,7 +1147,7 @@ static long do_mbind(unsigned long start, unsigned long len, ...@@ -1147,7 +1147,7 @@ static long do_mbind(unsigned long start, unsigned long len,
if (start & ~PAGE_MASK) if (start & ~PAGE_MASK)
return -EINVAL; return -EINVAL;
if (mode == MPOL_DEFAULT) if (mode == MPOL_DEFAULT || mode == MPOL_NOOP)
flags &= ~MPOL_MF_STRICT; flags &= ~MPOL_MF_STRICT;
len = (len + PAGE_SIZE - 1) & PAGE_MASK; len = (len + PAGE_SIZE - 1) & PAGE_MASK;
...@@ -2409,7 +2409,8 @@ static const char * const policy_modes[] = ...@@ -2409,7 +2409,8 @@ static const char * const policy_modes[] =
[MPOL_PREFERRED] = "prefer", [MPOL_PREFERRED] = "prefer",
[MPOL_BIND] = "bind", [MPOL_BIND] = "bind",
[MPOL_INTERLEAVE] = "interleave", [MPOL_INTERLEAVE] = "interleave",
[MPOL_LOCAL] = "local" [MPOL_LOCAL] = "local",
[MPOL_NOOP] = "noop", /* should not actually be used */
}; };
...@@ -2460,7 +2461,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context) ...@@ -2460,7 +2461,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
break; break;
} }
} }
if (mode >= MPOL_MAX) if (mode >= MPOL_MAX || mode == MPOL_NOOP)
goto out; goto out;
switch (mode) { switch (mode) {
......
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