]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/mpol: Make MPOL_LOCAL a real policy
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Mon, 19 Mar 2012 17:54:52 +0000 (18:54 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 26 Sep 2012 09:48:31 +0000 (11:48 +0200)
Make MPOL_LOCAL a real and exposed policy such that applications that
relied on the previous default behaviour can explicitly request it.

Requested-by: Christoph Lameter <cl@linux.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.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 95b738c7abff9ac1e45a5e78e1daf1437b2283fd..7c73042db02fe7b3174814b791480ba0f9e446be 100644 (file)
@@ -20,6 +20,7 @@ enum {
        MPOL_PREFERRED,
        MPOL_BIND,
        MPOL_INTERLEAVE,
+       MPOL_LOCAL,
        MPOL_MAX,       /* always last member of enum */
 };
 
index 369cbb94c2e7b6e8c4cc9207bf735f18845433bf..19f99e870c931e9718b72e277fee2d06cb08cd31 100644 (file)
@@ -269,6 +269,10 @@ static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,
                             (flags & MPOL_F_RELATIVE_NODES)))
                                return ERR_PTR(-EINVAL);
                }
+       } else if (mode == MPOL_LOCAL) {
+               if (!nodes_empty(*nodes))
+                       return ERR_PTR(-EINVAL);
+               mode = MPOL_PREFERRED;
        } else if (nodes_empty(*nodes))
                return ERR_PTR(-EINVAL);
        policy = kmem_cache_alloc(policy_cache, GFP_KERNEL);
@@ -2330,7 +2334,6 @@ void numa_default_policy(void)
  * "local" is pseudo-policy:  MPOL_PREFERRED with MPOL_F_LOCAL flag
  * Used only for mpol_parse_str() and mpol_to_str()
  */
-#define MPOL_LOCAL MPOL_MAX
 static const char * const policy_modes[] =
 {
        [MPOL_DEFAULT]    = "default",
@@ -2383,12 +2386,12 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
        if (flags)
                *flags++ = '\0';        /* terminate mode string */
 
-       for (mode = 0; mode <= MPOL_LOCAL; mode++) {
+       for (mode = 0; mode < MPOL_MAX; mode++) {
                if (!strcmp(str, policy_modes[mode])) {
                        break;
                }
        }
-       if (mode > MPOL_LOCAL)
+       if (mode >= MPOL_MAX)
                goto out;
 
        switch (mode) {