aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mempolicy.h
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2008-04-28 05:12:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:19 -0400
commit028fec414d803117eb4b2ed12acb4dd5da65b32d (patch)
tree427f37ea0331369c1babc55c424c4fd2ac3b39f5 /include/linux/mempolicy.h
parenta3b51e0142d1be156ac697eaadadd6cfbb7ba32b (diff)
mempolicy: support optional mode flags
With the evolution of mempolicies, it is necessary to support mempolicy mode flags that specify how the policy shall behave in certain circumstances. The most immediate need for mode flag support is to suppress remapping the nodemask of a policy at the time of rebind. Both the mempolicy mode and flags are passed by the user in the 'int policy' formal of either the set_mempolicy() or mbind() syscall. A new constant, MPOL_MODE_FLAGS, represents the union of legal optional flags that may be passed as part of this int. Mempolicies that include illegal flags as part of their policy are rejected as invalid. An additional member to struct mempolicy is added to support the mode flags: struct mempolicy { ... unsigned short policy; unsigned short flags; } The splitting of the 'int' actual passed by the user is done in sys_set_mempolicy() and sys_mbind() for their respective syscalls. This is done by intersecting the actual with MPOL_MODE_FLAGS, rejecting the syscall of there are additional flags, and storing it in the new 'flags' member of struct mempolicy. The intersection of the actual with ~MPOL_MODE_FLAGS is stored in the 'policy' member of the struct and all current users of pol->policy remain unchanged. The union of the policy mode and optional mode flags is passed back to the user in get_mempolicy(). This combination of mode and flags within the same actual does not break userspace code that relies on get_mempolicy(&policy, ...) and either switch (policy) { case MPOL_BIND: ... case MPOL_INTERLEAVE: ... }; statements or if (policy == MPOL_INTERLEAVE) { ... } statements. Such applications would need to use optional mode flags when calling set_mempolicy() or mbind() for these previously implemented statements to stop working. If an application does start using optional mode flags, it will need to mask the optional flags off the policy in switch and conditional statements that only test mode. An additional member is also added to struct shmem_sb_info to store the optional mode flags. [hugh@veritas.com: shmem mpol: fix build warning] Cc: Paul Jackson <pj@sgi.com> Cc: Christoph Lameter <clameter@sgi.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com> Cc: Andi Kleen <ak@suse.de> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mempolicy.h')
-rw-r--r--include/linux/mempolicy.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 389a06e8ee2..f2bab4d2fc4 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -8,6 +8,12 @@
8 * Copyright 2003,2004 Andi Kleen SuSE Labs 8 * Copyright 2003,2004 Andi Kleen SuSE Labs
9 */ 9 */
10 10
11/*
12 * Both the MPOL_* mempolicy mode and the MPOL_F_* optional mode flags are
13 * passed by the user to either set_mempolicy() or mbind() in an 'int' actual.
14 * The MPOL_MODE_FLAGS macro determines the legal set of optional mode flags.
15 */
16
11/* Policies */ 17/* Policies */
12enum { 18enum {
13 MPOL_DEFAULT, 19 MPOL_DEFAULT,
@@ -17,7 +23,14 @@ enum {
17 MPOL_MAX, /* always last member of enum */ 23 MPOL_MAX, /* always last member of enum */
18}; 24};
19 25
20/* Flags for get_mem_policy */ 26/* Flags for set_mempolicy */
27/*
28 * MPOL_MODE_FLAGS is the union of all possible optional mode flags passed to
29 * either set_mempolicy() or mbind().
30 */
31#define MPOL_MODE_FLAGS (0)
32
33/* Flags for get_mempolicy */
21#define MPOL_F_NODE (1<<0) /* return next IL mode instead of node mask */ 34#define MPOL_F_NODE (1<<0) /* return next IL mode instead of node mask */
22#define MPOL_F_ADDR (1<<1) /* look up vma using address */ 35#define MPOL_F_ADDR (1<<1) /* look up vma using address */
23#define MPOL_F_MEMS_ALLOWED (1<<2) /* return allowed memories */ 36#define MPOL_F_MEMS_ALLOWED (1<<2) /* return allowed memories */
@@ -66,6 +79,7 @@ struct mm_struct;
66struct mempolicy { 79struct mempolicy {
67 atomic_t refcnt; 80 atomic_t refcnt;
68 unsigned short policy; /* See MPOL_* above */ 81 unsigned short policy; /* See MPOL_* above */
82 unsigned short flags; /* See set_mempolicy() MPOL_F_* above */
69 union { 83 union {
70 short preferred_node; /* preferred */ 84 short preferred_node; /* preferred */
71 nodemask_t nodes; /* interleave/bind */ 85 nodemask_t nodes; /* interleave/bind */
@@ -136,7 +150,7 @@ struct shared_policy {
136}; 150};
137 151
138void mpol_shared_policy_init(struct shared_policy *info, unsigned short policy, 152void mpol_shared_policy_init(struct shared_policy *info, unsigned short policy,
139 nodemask_t *nodes); 153 unsigned short flags, nodemask_t *nodes);
140int mpol_set_shared_policy(struct shared_policy *info, 154int mpol_set_shared_policy(struct shared_policy *info,
141 struct vm_area_struct *vma, 155 struct vm_area_struct *vma,
142 struct mempolicy *new); 156 struct mempolicy *new);
@@ -203,7 +217,7 @@ static inline int mpol_set_shared_policy(struct shared_policy *info,
203} 217}
204 218
205static inline void mpol_shared_policy_init(struct shared_policy *info, 219static inline void mpol_shared_policy_init(struct shared_policy *info,
206 unsigned short policy, nodemask_t *nodes) 220 unsigned short policy, unsigned short flags, nodemask_t *nodes)
207{ 221{
208} 222}
209 223