aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mempolicy.h
diff options
context:
space:
mode:
authorLee Schermerhorn <lee.schermerhorn@hp.com>2008-04-28 05:13:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:25 -0400
commit71fe804b6d56d6a7aed680e096901434cef6a2c3 (patch)
tree3dd437e09fe6ee57644c72c79e08c562d4bb6389 /include/linux/mempolicy.h
parent3f226aa1cbc006f9d90f22084f519ad2a1286cd8 (diff)
mempolicy: use struct mempolicy pointer in shmem_sb_info
This patch replaces the mempolicy mode, mode_flags, and nodemask in the shmem_sb_info struct with a struct mempolicy pointer, initialized to NULL. This removes dependency on the details of mempolicy from shmem.c and hugetlbfs inode.c and simplifies the interfaces. mpol_parse_str() in mempolicy.c is changed to return, via a pointer to a pointer arg, a struct mempolicy pointer on success. For MPOL_DEFAULT, the returned pointer is NULL. Further, mpol_parse_str() now takes a 'no_context' argument that causes the input nodemask to be stored in the w.user_nodemask of the created mempolicy for use when the mempolicy is installed in a tmpfs inode shared policy tree. At that time, any cpuset contextualization is applied to the original input nodemask. This preserves the previous behavior where the input nodemask was stored in the superblock. We can think of the returned mempolicy as "context free". Because mpol_parse_str() is now calling mpol_new(), we can remove from mpol_to_str() the semantic checks that mpol_new() already performs. Add 'no_context' parameter to mpol_to_str() to specify that it should format the nodemask in w.user_nodemask for 'bind' and 'interleave' policies. Change mpol_shared_policy_init() to take a pointer to a "context free" struct mempolicy and to create a new, "contextualized" mempolicy using the mode, mode_flags and user_nodemask from the input mempolicy. Note: we know that the mempolicy passed to mpol_to_str() or mpol_shared_policy_init() from a tmpfs superblock is "context free". This is currently the only instance thereof. However, if we found more uses for this concept, and introduced any ambiguity as to whether a mempolicy was context free or not, we could add another internal mode flag to identify context free mempolicies. Then, we could remove the 'no_context' argument from mpol_to_str(). Added shmem_get_sbmpol() to return a reference counted superblock mempolicy, if one exists, to pass to mpol_shared_policy_init(). We must add the reference under the sb stat_lock to prevent races with replacement of the mpol by remount. This reference is removed in mpol_shared_policy_init(). [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: another build fix] [akpm@linux-foundation.org: yet another build fix] 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 'include/linux/mempolicy.h')
-rw-r--r--include/linux/mempolicy.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index dcc17378c952..3a39570b81b8 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -182,8 +182,7 @@ struct shared_policy {
182 spinlock_t lock; 182 spinlock_t lock;
183}; 183};
184 184
185void mpol_shared_policy_init(struct shared_policy *info, unsigned short mode, 185void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol);
186 unsigned short flags, nodemask_t *nodes);
187int mpol_set_shared_policy(struct shared_policy *info, 186int mpol_set_shared_policy(struct shared_policy *info,
188 struct vm_area_struct *vma, 187 struct vm_area_struct *vma,
189 struct mempolicy *new); 188 struct mempolicy *new);
@@ -216,10 +215,10 @@ int do_migrate_pages(struct mm_struct *mm,
216 215
217 216
218#ifdef CONFIG_TMPFS 217#ifdef CONFIG_TMPFS
219extern int mpol_parse_str(char *str, unsigned short *mode, 218extern int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context);
220 unsigned short *mode_flags, nodemask_t *policy_nodes);
221 219
222extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol); 220extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
221 int no_context);
223#endif 222#endif
224#else 223#else
225 224
@@ -262,8 +261,8 @@ static inline int mpol_set_shared_policy(struct shared_policy *info,
262 return -EINVAL; 261 return -EINVAL;
263} 262}
264 263
265static inline void mpol_shared_policy_init(struct shared_policy *info, 264static inline void mpol_shared_policy_init(struct shared_policy *sp,
266 unsigned short mode, unsigned short flags, nodemask_t *nodes) 265 struct mempolicy *mpol)
267{ 266{
268} 267}
269 268
@@ -322,13 +321,14 @@ static inline void check_highest_zone(int k)
322} 321}
323 322
324#ifdef CONFIG_TMPFS 323#ifdef CONFIG_TMPFS
325static inline int mpol_parse_str(char *value, unsigned short *policy, 324static inline int mpol_parse_str(char *str, struct mempolicy **mpol,
326 unsigned short flags, nodemask_t *policy_nodes) 325 int no_context)
327{ 326{
328 return 1; 327 return 1; /* error */
329} 328}
330 329
331static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) 330static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
331 int no_context)
332{ 332{
333 return 0; 333 return 0;
334} 334}