summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLee Schermerhorn <lee.schermerhorn@hp.com>2008-04-28 02:13:24 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 08:58:25 -0700
commit3f226aa1cbc006f9d90f22084f519ad2a1286cd8 (patch)
treee54a87abb19f9dea184f4c17c4c8532d3d715de8 /mm
parent095f1fc4ebf36c64fddf9b6db29b1ab5517378e6 (diff)
downloadlinux-3f226aa1cbc006f9d90f22084f519ad2a1286cd8.tar.bz2
mempolicy: support mpol=local tmpfs mount option
For tmpfs/shmem shared policies, MPOL_DEFAULT is not necessarily equivalent to "local allocation". Because shared policies are at the same "scope" level [see Documentation/vm/numa_memory_policy.txt], as vma policies MPOL_DEFAULT means "fall back to current task policy". This patch extends the memory policy string parsing function to display "local" for MPOL_PREFERRED + MPOL_F_LOCAL. This allows one to specify local allocation as the default policy for shared memory areas via the tmpfs mpol mount option, regardless of the current task's policy. Also, "local" is now displayed for this policy. This patch allows us to accept the same input format as the display. Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: Christoph Lameter <clameter@sgi.com> Cc: David Rientjes <rientjes@google.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/mempolicy.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 155bb284dbf1..6b751565eed1 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1951,7 +1951,7 @@ void numa_default_policy(void)
/*
* "local" is pseudo-policy: MPOL_PREFERRED with MPOL_F_LOCAL flag
- * Used only for mpol_to_str()
+ * Used only for mpol_parse_str() and mpol_to_str()
*/
#define MPOL_LOCAL (MPOL_INTERLEAVE + 1)
static const char * const policy_types[] =
@@ -1990,21 +1990,16 @@ int mpol_parse_str(char *str, unsigned short *mode, unsigned short *mode_flags,
if (flags)
*flags++ = '\0'; /* terminate mode string */
- for (i = 0; i < MPOL_MAX; i++) {
+ for (i = 0; i <= MPOL_LOCAL; i++) {
if (!strcmp(str, policy_types[i])) {
*mode = i;
break;
}
}
- if (i == MPOL_MAX)
+ if (i > MPOL_LOCAL)
goto out;
switch (*mode) {
- case MPOL_DEFAULT:
- /* Don't allow a nodelist nor flags */
- if (!nodelist && !flags)
- err = 0;
- break;
case MPOL_PREFERRED:
/* Insist on a nodelist of one node only */
if (nodelist) {
@@ -2027,6 +2022,20 @@ int mpol_parse_str(char *str, unsigned short *mode, unsigned short *mode_flags,
if (!nodelist)
*policy_nodes = node_states[N_HIGH_MEMORY];
err = 0;
+ break;
+ default:
+ /*
+ * MPOL_DEFAULT or MPOL_LOCAL
+ * Don't allow a nodelist nor flags
+ */
+ if (!nodelist && !flags)
+ err = 0;
+ if (*mode == MPOL_DEFAULT)
+ goto out;
+ /* else MPOL_LOCAL */
+ *mode = MPOL_PREFERRED;
+ nodes_clear(*policy_nodes);
+ break;
}
*mode_flags = 0;