aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempolicy.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r--mm/mempolicy.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index acb5ee3587c3..1311dc4a3888 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -114,7 +114,7 @@ static void mpol_rebind_policy(struct mempolicy *pol,
114 const nodemask_t *newmask); 114 const nodemask_t *newmask);
115 115
116/* Do sanity checking on a policy */ 116/* Do sanity checking on a policy */
117static int mpol_check_policy(int mode, nodemask_t *nodes) 117static int mpol_check_policy(unsigned short mode, nodemask_t *nodes)
118{ 118{
119 int was_empty, is_empty; 119 int was_empty, is_empty;
120 120
@@ -159,6 +159,8 @@ static int mpol_check_policy(int mode, nodemask_t *nodes)
159 if (!was_empty && is_empty) 159 if (!was_empty && is_empty)
160 return -EINVAL; 160 return -EINVAL;
161 break; 161 break;
162 default:
163 BUG();
162 } 164 }
163 return 0; 165 return 0;
164} 166}
@@ -185,7 +187,7 @@ static int is_valid_nodemask(nodemask_t *nodemask)
185} 187}
186 188
187/* Create a new policy */ 189/* Create a new policy */
188static struct mempolicy *mpol_new(int mode, nodemask_t *nodes) 190static struct mempolicy *mpol_new(unsigned short mode, nodemask_t *nodes)
189{ 191{
190 struct mempolicy *policy; 192 struct mempolicy *policy;
191 193
@@ -218,6 +220,8 @@ static struct mempolicy *mpol_new(int mode, nodemask_t *nodes)
218 } 220 }
219 policy->v.nodes = *nodes; 221 policy->v.nodes = *nodes;
220 break; 222 break;
223 default:
224 BUG();
221 } 225 }
222 policy->policy = mode; 226 policy->policy = mode;
223 policy->cpuset_mems_allowed = cpuset_mems_allowed(current); 227 policy->cpuset_mems_allowed = cpuset_mems_allowed(current);
@@ -462,7 +466,7 @@ static void mpol_set_task_struct_flag(void)
462} 466}
463 467
464/* Set the process memory policy */ 468/* Set the process memory policy */
465static long do_set_mempolicy(int mode, nodemask_t *nodes) 469static long do_set_mempolicy(unsigned short mode, nodemask_t *nodes)
466{ 470{
467 struct mempolicy *new; 471 struct mempolicy *new;
468 472
@@ -759,7 +763,7 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int *
759#endif 763#endif
760 764
761static long do_mbind(unsigned long start, unsigned long len, 765static long do_mbind(unsigned long start, unsigned long len,
762 unsigned long mode, nodemask_t *nmask, 766 unsigned short mode, nodemask_t *nmask,
763 unsigned long flags) 767 unsigned long flags)
764{ 768{
765 struct vm_area_struct *vma; 769 struct vm_area_struct *vma;
@@ -769,9 +773,8 @@ static long do_mbind(unsigned long start, unsigned long len,
769 int err; 773 int err;
770 LIST_HEAD(pagelist); 774 LIST_HEAD(pagelist);
771 775
772 if ((flags & ~(unsigned long)(MPOL_MF_STRICT | 776 if (flags & ~(unsigned long)(MPOL_MF_STRICT |
773 MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) 777 MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
774 || mode > MPOL_MAX)
775 return -EINVAL; 778 return -EINVAL;
776 if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_NICE)) 779 if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_NICE))
777 return -EPERM; 780 return -EPERM;
@@ -804,7 +807,7 @@ static long do_mbind(unsigned long start, unsigned long len,
804 if (!new) 807 if (!new)
805 flags |= MPOL_MF_DISCONTIG_OK; 808 flags |= MPOL_MF_DISCONTIG_OK;
806 809
807 pr_debug("mbind %lx-%lx mode:%ld nodes:%lx\n",start,start+len, 810 pr_debug("mbind %lx-%lx mode:%d nodes:%lx\n", start, start + len,
808 mode, nmask ? nodes_addr(*nmask)[0] : -1); 811 mode, nmask ? nodes_addr(*nmask)[0] : -1);
809 812
810 down_write(&mm->mmap_sem); 813 down_write(&mm->mmap_sem);
@@ -905,6 +908,8 @@ asmlinkage long sys_mbind(unsigned long start, unsigned long len,
905 nodemask_t nodes; 908 nodemask_t nodes;
906 int err; 909 int err;
907 910
911 if (mode >= MPOL_MAX)
912 return -EINVAL;
908 err = get_nodes(&nodes, nmask, maxnode); 913 err = get_nodes(&nodes, nmask, maxnode);
909 if (err) 914 if (err)
910 return err; 915 return err;
@@ -918,7 +923,7 @@ asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
918 int err; 923 int err;
919 nodemask_t nodes; 924 nodemask_t nodes;
920 925
921 if (mode < 0 || mode > MPOL_MAX) 926 if (mode < 0 || mode >= MPOL_MAX)
922 return -EINVAL; 927 return -EINVAL;
923 err = get_nodes(&nodes, nmask, maxnode); 928 err = get_nodes(&nodes, nmask, maxnode);
924 if (err) 929 if (err)
@@ -1201,7 +1206,7 @@ static unsigned interleave_nodes(struct mempolicy *policy)
1201 */ 1206 */
1202unsigned slab_node(struct mempolicy *policy) 1207unsigned slab_node(struct mempolicy *policy)
1203{ 1208{
1204 int pol = policy ? policy->policy : MPOL_DEFAULT; 1209 unsigned short pol = policy ? policy->policy : MPOL_DEFAULT;
1205 1210
1206 switch (pol) { 1211 switch (pol) {
1207 case MPOL_INTERLEAVE: 1212 case MPOL_INTERLEAVE:
@@ -1635,7 +1640,7 @@ restart:
1635 return 0; 1640 return 0;
1636} 1641}
1637 1642
1638void mpol_shared_policy_init(struct shared_policy *info, int policy, 1643void mpol_shared_policy_init(struct shared_policy *info, unsigned short policy,
1639 nodemask_t *policy_nodes) 1644 nodemask_t *policy_nodes)
1640{ 1645{
1641 info->root = RB_ROOT; 1646 info->root = RB_ROOT;
@@ -1830,7 +1835,7 @@ static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
1830 char *p = buffer; 1835 char *p = buffer;
1831 int l; 1836 int l;
1832 nodemask_t nodes; 1837 nodemask_t nodes;
1833 int mode = pol ? pol->policy : MPOL_DEFAULT; 1838 unsigned short mode = pol ? pol->policy : MPOL_DEFAULT;
1834 1839
1835 switch (mode) { 1840 switch (mode) {
1836 case MPOL_DEFAULT: 1841 case MPOL_DEFAULT: