From a77259b0b81a42c1088bbacce74c4a6587d4272e Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 25 Oct 2012 14:16:28 +0200 Subject: [PATCH] --- yaml --- r: 344787 b: refs/heads/master c: 479e2802d09f1e18a97262c4c6f8f17ae5884bd8 h: refs/heads/master i: 344785: c40af3a960b316e3e7546384bd99f91bfee81f2f 344783: 409cb0f14de7f44756da532e1d7d870f155dbd63 v: v3 --- [refs] | 2 +- trunk/include/uapi/linux/mempolicy.h | 1 + trunk/mm/mempolicy.c | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index e2bf78543b4c..59e668de887a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d10e63f29488b0f312a443f9507ea9b6fd3c9090 +refs/heads/master: 479e2802d09f1e18a97262c4c6f8f17ae5884bd8 diff --git a/trunk/include/uapi/linux/mempolicy.h b/trunk/include/uapi/linux/mempolicy.h index 23e62e0537e2..3e835c9d847b 100644 --- a/trunk/include/uapi/linux/mempolicy.h +++ b/trunk/include/uapi/linux/mempolicy.h @@ -20,6 +20,7 @@ enum { MPOL_PREFERRED, MPOL_BIND, MPOL_INTERLEAVE, + MPOL_LOCAL, MPOL_MAX, /* always last member of enum */ }; diff --git a/trunk/mm/mempolicy.c b/trunk/mm/mempolicy.c index 66e90ecc2350..54bd3e5ed776 100644 --- a/trunk/mm/mempolicy.c +++ b/trunk/mm/mempolicy.c @@ -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); @@ -2399,7 +2403,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", @@ -2452,12 +2455,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) {