aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempolicy.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@bruce>2006-03-21 23:31:14 -0500
committerNathan Scott <nathans@bruce>2006-03-21 23:31:14 -0500
commit4d74f423c722b8cadfabe087369200013b217b67 (patch)
treed62facddfdb0dfd89f3e61f4fc699cf2feb4b082 /mm/mempolicy.c
parentbb19fba1937cb6ab2bb98ac893365f6ebf88ef1b (diff)
parente952f31bce6e9f64db01f607abc46529ba57ac9e (diff)
Merge HEAD from ../linux-2.6
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r--mm/mempolicy.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 954981b14303..b21869a39f0b 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -330,9 +330,19 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
330 int err; 330 int err;
331 struct vm_area_struct *first, *vma, *prev; 331 struct vm_area_struct *first, *vma, *prev;
332 332
333 /* Clear the LRU lists so pages can be isolated */ 333 if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {
334 if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) 334 /* Must have swap device for migration */
335 if (nr_swap_pages <= 0)
336 return ERR_PTR(-ENODEV);
337
338 /*
339 * Clear the LRU lists so pages can be isolated.
340 * Note that pages may be moved off the LRU after we have
341 * drained them. Those pages will fail to migrate like other
342 * pages that may be busy.
343 */
335 lru_add_drain_all(); 344 lru_add_drain_all();
345 }
336 346
337 first = find_vma(mm, start); 347 first = find_vma(mm, start);
338 if (!first) 348 if (!first)
@@ -748,7 +758,7 @@ long do_mbind(unsigned long start, unsigned long len,
748 MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) 758 MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
749 || mode > MPOL_MAX) 759 || mode > MPOL_MAX)
750 return -EINVAL; 760 return -EINVAL;
751 if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_RESOURCE)) 761 if ((flags & MPOL_MF_MOVE_ALL) && !capable(CAP_SYS_NICE))
752 return -EPERM; 762 return -EPERM;
753 763
754 if (start & ~PAGE_MASK) 764 if (start & ~PAGE_MASK)
@@ -942,20 +952,20 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
942 */ 952 */
943 if ((current->euid != task->suid) && (current->euid != task->uid) && 953 if ((current->euid != task->suid) && (current->euid != task->uid) &&
944 (current->uid != task->suid) && (current->uid != task->uid) && 954 (current->uid != task->suid) && (current->uid != task->uid) &&
945 !capable(CAP_SYS_ADMIN)) { 955 !capable(CAP_SYS_NICE)) {
946 err = -EPERM; 956 err = -EPERM;
947 goto out; 957 goto out;
948 } 958 }
949 959
950 task_nodes = cpuset_mems_allowed(task); 960 task_nodes = cpuset_mems_allowed(task);
951 /* Is the user allowed to access the target nodes? */ 961 /* Is the user allowed to access the target nodes? */
952 if (!nodes_subset(new, task_nodes) && !capable(CAP_SYS_ADMIN)) { 962 if (!nodes_subset(new, task_nodes) && !capable(CAP_SYS_NICE)) {
953 err = -EPERM; 963 err = -EPERM;
954 goto out; 964 goto out;
955 } 965 }
956 966
957 err = do_migrate_pages(mm, &old, &new, 967 err = do_migrate_pages(mm, &old, &new,
958 capable(CAP_SYS_ADMIN) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE); 968 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
959out: 969out:
960 mmput(mm); 970 mmput(mm);
961 return err; 971 return err;