linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] sys_migrate_pages: Allow the specification of migration options
@ 2006-02-25  1:42 Christoph Lameter
  2006-02-25  5:21 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Lameter @ 2006-02-25  1:42 UTC (permalink / raw)
  To: ak, Lee Schermerhorn, linux-mm, akpm

Andi, 

Andrew suggested to add another parameter to sys_migrate_pages in an 
earlier thread. We discussed a patch that made sys_migrate_pages 
move all pages of a process when invoked as root. Here is an alternate 
patch adding a parameter that would give root control if migrate_pages 
will move pages referenced only by the specified process or all 
referenced pages.

This would break numactl and require another update cycle. What would you 
prefer? And if we do this could be get all of the functionality into 
SLES10 in time?



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 <clameter@sgi.com>

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;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-25  5:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-25  1:42 [RFC] sys_migrate_pages: Allow the specification of migration options Christoph Lameter
2006-02-25  5:21 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox