sys_migrate_pages: Allow the specification of migration options Currently sys_migrate_pages only moves pages belonging to a process. This is okay when invoked from a regular user. But if invoked from root it would be nice to have other options. This patch adds a flag argument (comparable to mbind()) where one could specify MPOL_MOVE_ALL to migrate all pages (do_migrate_pages already has that parameter). However, doing that will break the current code for libnuma and migratepages as well as require an update of the documentation in the numactl package. Signed-off-by: Christoph Lameter Index: linux-2.6.16-rc4/mm/mempolicy.c =================================================================== --- linux-2.6.16-rc4.orig/mm/mempolicy.c 2006-02-24 16:20:53.000000000 -0800 +++ linux-2.6.16-rc4/mm/mempolicy.c 2006-02-24 17:17:02.000000000 -0800 @@ -890,7 +890,7 @@ asmlinkage long sys_set_mempolicy(int mo asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, const unsigned long __user *old_nodes, - const unsigned long __user *new_nodes) + const unsigned long __user *new_nodes, int flags) { struct mm_struct *mm; struct task_struct *task; @@ -899,6 +899,12 @@ asmlinkage long sys_migrate_pages(pid_t nodemask_t task_nodes; int err; + /* + * Check for invalid flags + */ + if (flags & ~(MPOL_MF_MOVE_ALL | MPOL_MF_MOVE)) + return -EINVAL; + err = get_nodes(&old, old_nodes, maxnode); if (err) return err; @@ -940,7 +946,14 @@ asmlinkage long sys_migrate_pages(pid_t goto out; } - err = do_migrate_pages(mm, &old, &new, MPOL_MF_MOVE); + /* Only a superuser can specify MPOL_MF_MOVE_ALL) */ + if (!capable(CAP_SYS_ADMIN) && (flags & MPOL_MF_MOVE_ALL)) { + err = -EPERM; + goto out; + } + + err = do_migrate_pages(mm, &old, &new, + flags & (MPOL_MF_MOVE_ALL|MPOL_MF_MOVE)); out: mmput(mm); return err;