Skip to content

Commit d3a7103

Browse files
Lee SchermerhornMel Gorman
authored andcommitted
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: Reported-by: Fengguang Wu <fengguang.wu@intel.com> 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> Signed-off-by: Mel Gorman <mgorman@suse.de>
1 parent 479e280 commit d3a7103

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

include/uapi/linux/mempolicy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ enum {
2121
MPOL_BIND,
2222
MPOL_INTERLEAVE,
2323
MPOL_LOCAL,
24+
MPOL_NOOP, /* retain existing policy for range */
2425
MPOL_MAX, /* always last member of enum */
2526
};
2627

mm/mempolicy.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,
251251
pr_debug("setting mode %d flags %d nodes[0] %lx\n",
252252
mode, flags, nodes ? nodes_addr(*nodes)[0] : -1);
253253

254-
if (mode == MPOL_DEFAULT) {
254+
if (mode == MPOL_DEFAULT || mode == MPOL_NOOP) {
255255
if (nodes && !nodes_empty(*nodes))
256256
return ERR_PTR(-EINVAL);
257-
return NULL; /* simply delete any existing policy */
257+
return NULL;
258258
}
259259
VM_BUG_ON(!nodes);
260260

@@ -1147,7 +1147,7 @@ static long do_mbind(unsigned long start, unsigned long len,
11471147
if (start & ~PAGE_MASK)
11481148
return -EINVAL;
11491149

1150-
if (mode == MPOL_DEFAULT)
1150+
if (mode == MPOL_DEFAULT || mode == MPOL_NOOP)
11511151
flags &= ~MPOL_MF_STRICT;
11521152

11531153
len = (len + PAGE_SIZE - 1) & PAGE_MASK;
@@ -2409,7 +2409,8 @@ static const char * const policy_modes[] =
24092409
[MPOL_PREFERRED] = "prefer",
24102410
[MPOL_BIND] = "bind",
24112411
[MPOL_INTERLEAVE] = "interleave",
2412-
[MPOL_LOCAL] = "local"
2412+
[MPOL_LOCAL] = "local",
2413+
[MPOL_NOOP] = "noop", /* should not actually be used */
24132414
};
24142415

24152416

@@ -2460,7 +2461,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
24602461
break;
24612462
}
24622463
}
2463-
if (mode >= MPOL_MAX)
2464+
if (mode >= MPOL_MAX || mode == MPOL_NOOP)
24642465
goto out;
24652466

24662467
switch (mode) {

0 commit comments

Comments
 (0)