sys_move_pages() updates
cover sys_move_pages() updates
These patches are against 2.6.17-rc4-mm3 and complete the implementation of sys_move_pages().
1. Fix brokenness in follow_page introduced with the dirty pages patch.
2. Extract common permissions check
3. Fixups sys_move_pages()
4. x86_64 support
5. 32 bit support for i386, x86_64 and ia64.
PATCH 1/5 follow_page: do not put_page if FOLL_GET not specified.
follow: no put_page() if FOLL_GET not specified.
Seems that one of the side effects of the dirty pages patch in 2.6.17-rc4-mm3 is that follow_pages does a page_put if FOLL_GET is not set in the flags passed to it. This breaks sys_move_pages() page status determination.
Only put_page if we did a get_page() before.
Index: linux-2.6.17-rc4-mm3/mm/memory.c
=================================--- linux-2.6.17-rc4-mm3.orig/mm/memory.c 2006-05-22 18:03:32.280767264 -0700
+++ linux-2.6.17-rc4-mm3/mm/memory.c 2006-05-23 10:01:48.917295988 -0700
@@ -964,7 +964,7 @@ struct page *follow_page(struct vm_area_
set_page_dirty(page);
mark_page_accessed(page);
}
- if (!(flags & FOLL_GET))
+ if (!(flags & FOLL_GET) && (flags & FOLL_TOUCH))
put_page(page);
goto out;
Re: [1/5] follow_page: do not put_page if FOLL_GET not specified.
Quoted 10 lines · Christoph Lameter
follow: no
put_page()ifFOLL_GETnot specified.Seems that one of the side effects of the dirty pages patch in 2.6.17-rc4-mm3 is that
follow_pagesdoes apage_putifFOLL_GETis not set in the flags passed to it. This breakssys_move_pages()page status determination.Only
put_pageif we did aget_page()before.Signed-off-by Christoph Lameter <[email protected]>
However, Andrew dropped the patches from -mm. I'll do a new series that incorporates the suggestions from Hugh.
Quoted 12 lines
Index:
linux-2.6.17-rc4-mm3/mm/memory.c
=================================> ---linux-2.6.17-rc4-mm3.orig/mm/memory.c2006-05-22 18:03:32.280767264 -0700
+++linux-2.6.17-rc4-mm3/mm/memory.c2006-05-23 10:01:48.917295988 -0700(quoted diff) +1
-1@@ -964,7 +964,7 @@ struct page *follow_page(struct vm_area_ set_page_dirty(page); mark_page_accessed(page); } - if (!(flags & FOLL_GET)) + if (!(flags & FOLL_GET) && (flags & FOLL_TOUCH)) put_page(page); goto out;
PATCH 2/5 extract common code to have_task_perm()
In reply to Christoph LameterExtract have_task_perm()
Various kernel function check if they are allowed to do something to another task. The ones that I have found are
1. The check for kill permissions
2. sys_migrate_pages() checking if a process is allowed to migrate the pages of another process.
3. sys_move_pages() checking if a process is allowed to migrate individual pages that are part of another process.
Extract the common code in these checks to form a new function in kernel/signal.c have_task_perm(task, capability). The check is successful if
1. The current process has the indicated capability
2. The current effective userid is equal to the suid or uid of the target process.
3. The current userid is equal to the suid or uid of the target process.
Note that there are similar checks for uid/gid/euid that are stored in a variety of structures in the kernel. Maybe those may also be extracted by a similar function that would not take a task parameter but an explicit specification of permission ids?
ptrace() has a variation on the have_task_perm() check in may_attach(). ptrace checks for uid equal to euid, suid, uid or gid equal to egid sgid,gid. So one may not be able to kill a process explicyly but be able to ptrace() (and then PTRACE_KILL it) if one is a member of the same group? Weird.
Plus ptrace does not support eid comparision. So explicit rights for ptracing cannot be set via the super user bit.
Maybe we could consolidate all these checks and make them work in a coherent way? I dont think I am deep enough into this issue to takle that though.
Index: linux-2.6.17-rc4-mm3/mm/mempolicy.c
=================================--- linux-2.6.17-rc4-mm3.orig/mm/mempolicy.c 2006-05-22 18:03:32.283696770 -0700
+++ linux-2.6.17-rc4-mm3/mm/mempolicy.c 2006-05-23 08:55:24.371254745 -0700
@@ -926,15 +926,7 @@ asmlinkage long sys_migrate_pages(pid_t
if (!mm)
return -EINVAL;
- /*
- * Check if this process has the right to modify the specified
- * process. The right exists if the process has administrative
- * capabilities, superuser privileges or the same
- * userid as the target process.
- */
- if ((current->euid != task->suid) && (current->euid != task->uid) &&
- (current->uid != task->suid) && (current->uid != task->uid) &&
- !capable(CAP_SYS_NICE)) {
+ if (!have_task_perm(task, CAP_SYS_NICE)) {
err = -EPERM;
goto out;
}
Index: linux-2.6.17-rc4-mm3/mm/migrate.c
=================================--- linux-2.6.17-rc4-mm3.orig/mm/migrate.c 2006-05-22 18:03:32.286626275 -0700
+++ linux-2.6.17-rc4-mm3/mm/migrate.c 2006-05-23 08:55:24.372231247 -0700
@@ -781,15 +781,7 @@ asmlinkage long sys_move_pages(int pid,
if (!mm)
return -EINVAL;
- /*
- * Check if this process has the right to modify the specified
- * process. The right exists if the process has administrative
- * capabilities, superuser privileges or the same
- * userid as the target process.
- */
- if ((current->euid != task->suid) && (current->euid != task->uid) &&
- (current->uid != task->suid) && (current->uid != task->uid) &&
- !capable(CAP_SYS_NICE)) {
+ if (!have_task_perm(task, CAP_SYS_NICE)) {
err = -EPERM;
goto out2;
}
Index: linux-2.6.17-rc4-mm3/kernel/signal.c
=================================--- linux-2.6.17-rc4-mm3.orig/kernel/signal.c 2006-05-22 18:03:32.211435632 -0700
+++ linux-2.6.17-rc4-mm3/kernel/signal.c 2006-05-23 09:11:44.323266538 -0700
@@ -567,6 +567,25 @@ static int rm_from_queue(unsigned long m
}
/*
+ * Check if this process has the rights to do something
+ * with another process.
+ *
+ * The right exists if either
+ * 1. The current process has the indicated capability
+ * 2. The current effective user id is the user or superuser
+ * id of the other process.
+ * 3. The current user id is the user or superuser id of the other process.
+ */
+int have_task_perm(struct task_struct *t, int capability)
+{
+ if (capable(capability))
+ return 1;
+
+ return (current->euid = t->suid || current->euid = t->uid ||
+ current->uid = t->suid || current->uid = t->uid);
+}
+
+/*
* Bad permissions for sending the signal
*/
static int check_kill_permission(int sig, struct siginfo *info,
@@ -579,9 +598,7 @@ static int check_kill_permission(int sig
if ((info = SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
&& ((sig != SIGCONT) ||
(current->signal->session != t->signal->session))
- && (current->euid ^ t->suid) && (current->euid ^ t->uid) - && (current->uid ^ t->suid) && (current->uid ^ t->uid) - && !capable(CAP_KILL)) + && !have_task_perm(t, CAP_KILL))
return error;
error = security_task_kill(t, info, sig);
Index: linux-2.6.17-rc4-mm3/include/linux/signal.h
=================================--- linux-2.6.17-rc4-mm3.orig/include/linux/signal.h 2006-05-22 18:03:31.841341429 -0700
+++ linux-2.6.17-rc4-mm3/include/linux/signal.h 2006-05-23 08:55:24.393714292 -0700
@@ -267,6 +267,8 @@ extern int sigprocmask(int, sigset_t *,
struct pt_regs;
extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
+extern int have_task_perm(struct task_struct *, int); +
#endif /* __KERNEL__ */
#endif /* _LINUX_SIGNAL_H */
PATCH 3/5 move_pages: lots of fixups
In reply to Christoph LameterFix up sys_move_pages()
1. Update comments and documentation.
2. Make the page array passed to sys_move_pages void **
3. Check for boundary conditions on the size of the pm array.
4. Use vmalloc for page array instead of kmalloc().
5. Process parameters before taking mmap_sem
6. Add the required call to migrate_prep().
7. Extract a couple of functions to simplify the function.
8. Add function prototype in include/linux/syscalls.h
9. Disambiguify the page status codes and the return code of the function.
10. Do not migrate reserved pages (zero pages etc)
Updated description of the function call:
move_pages() is used to move individual pages of a process. The function can be used to determine the location of pages and to move them onto the desired node. move_pages() returns status information for each page.
long move_pages(pid, number_of_pages_to_move,
addresses_of_pages[], nodes[] or NULL, status[], flags);
The addresses of pages is an array of void * pointing to the pages to be moved.
The nodes array contains the node numbers that the pages should be moved to. If a NULL is passed instead of an array then no pages are moved but the status array is updated. The status request may be used to determine the page state before issuing another move_pages() to move pages.
The status array will contain the state of all individual page migration attempts when the function terminates. The status array is only valid if move_pages() completed successfullly.
Possible page states in status[]:
0..MAX_NUMNODES The page is now on the indicated node.
-ENOENT Page is not present
-EACCES Page is mapped by multiple processes and can only
be moved if MPOL_MF_MOVE_ALL is specified.
-EPERM The page has been mlocked by a process/driver and
cannot be moved.
-EBUSY Page is busy and cannot be moved. Try again later.
-EFAULT Invalid address (no VMA or zero page).
-ENOMEM Unable to allocate memory on target node.
-EIO Unable to write back page. The page must be written
back in order to move it since the page is dirty and the filesystem does not provide a migration function that would allow the moving of dirty pages.
-EINVAL A dirty page cannot be moved. The filesystem does not provide
a migration function and has no ability to write back pages.
The flags parameter indicates what types of pages to move:
MPOL_MF_MOVE Move pages that are only mapped by the process.
MPOL_MF_MOVE_ALL Also move pages that are mapped by multiple processes.
Requires sufficient capabilities.
Possible return codes from move_pages()
-ENOENT No pages found that would require moving. All pages
are either already on the target node, not present, had an invalid address or could not be moved because they were mapped by multiple processes.
-EINVAL Flags other than MPOL_MF_MOVE(_ALL) specified or an attempt
to migrate pages in a kernel thread.
-EPERM MPOL_MF_MOVE_ALL specified without sufficient priviledges.
or an attempt to move a process belonging to another user.
-EACCES One of the target nodes is not allowed by the current cpuset.
-ENODEV One of the target nodes is not online.
-ESRCH Process does not exist.
-E2BIG Too many pages to move.
-ENOMEM Not enough memory to allocate control array.
-EFAULT Parameters could not be accessed.
A test program for move_pages() may be found with the patches
on ftp.kernel.org:/pub/linux/kernel/people/christoph/pmig/patches-2.6.17-rc4-mm3
Index: linux-2.6.17-rc4-mm3/mm/migrate.c
=================================--- linux-2.6.17-rc4-mm3.orig/mm/migrate.c 2006-05-23 10:03:29.156194729 -0700
+++ linux-2.6.17-rc4-mm3/mm/migrate.c 2006-05-23 10:09:50.473360098 -0700
@@ -26,6 +26,7 @@
#include <linux/cpuset.h>
#include <linux/writeback.h>
#include <linux/mempolicy.h>
+#include <linux/vmalloc.h>
#include "internal.h"
@@ -63,9 +64,8 @@ int isolate_lru_page(struct page *page,
}
/*
- * migrate_prep() needs to be called after we have compiled the list of pages
- * to be migrated using isolate_lru_page() but before we begin a series of calls
- * to migrate_pages().
+ * migrate_prep() needs to be called before we start compiling a list of pages
+ * to be migrated using isolate_lru_page().
*/
int migrate_prep(void)
{
@@ -723,6 +723,7 @@ out:
* Move a list of individual pages
*/
struct page_to_node {
+ unsigned long addr;
struct page *page;
int node;
int status;
@@ -733,10 +734,10 @@ static struct page *new_page_node(struct
{
struct page_to_node *pm = (struct page_to_node *)private;
- while (pm->page && pm->page != p)
+ while (pm->node != MAX_NUMNODES && pm->page != p)
pm++;
- if (!pm->page)
+ if (pm->node = MAX_NUMNODES)
return NULL;
*result = &pm->status;
@@ -745,11 +746,122 @@ static struct page *new_page_node(struct
}
/*
+ * Move a set of pages as indicated in the pm array. The addr
+ * field must be set to the virtual address of the page to be moved
+ * and the node number must contain a valid target node.
+ */
+static int do_move_pages(struct mm_struct *mm, struct page_to_node *pm,
+ int migrate_all)
+{
+ int err;
+ struct page_to_node *pp;
+ LIST_HEAD(pagelist);
+
+ down_read(&mm->mmap_sem);
+
+ /*
+ * Build a list of pages to migrate
+ */
+ migrate_prep();
+ for (pp = pm; pp->node != MAX_NUMNODES; pp++) {
+ struct vm_area_struct *vma;
+ struct page *page;
+
+ /*
+ * A valid page pointer that will not match any of the
+ * pages that will be moved.
+ */
+ pp->page = ZERO_PAGE(0);
+
+ err = -EFAULT;
+ vma = find_vma(mm, pp->addr);
+ if (!vma)
+ goto set_status;
+
+ page = follow_page(vma, pp->addr, FOLL_GET);
+ err = -ENOENT;
+ if (!page)
+ goto set_status;
+
+ if (PageReserved(page)) /* Check for zero page */
+ goto put_and_set;
+
+ pp->page = page;
+ err = page_to_nid(page);
+
+ if (err = pp->node)
+ /*
+ * Node already in the right place
+ */
+ goto put_and_set;
+
+ err = -EACCES;
+ if (page_mapcount(page) > 1 &&
+ !migrate_all)
+ goto put_and_set;
+
+ err = isolate_lru_page(page, &pagelist);
+put_and_set:
+ /*
+ * Either remove the duplicate refcount from
+ * isolate_lru_page() or drop the page ref if it was
+ * not isolated.
+ */
+ put_page(page);
+set_status:
+ pp->status = err;
+ }
+
+ if (!list_empty(&pagelist))
+ err = migrate_pages(&pagelist, new_page_node,
+ (unsigned long)pm);
+ else
+ err = -ENOENT;
+
+ up_read(&mm->mmap_sem);
+ return err;
+}
+
+/*
+ * Determine the nodes of a list of pages. The addr in the pm array
+ * must have been set to the virtual address of which we want to determine
+ * the node number.
+ */
+static int do_pages_stat(struct mm_struct *mm, struct page_to_node *pm) +{
+ down_read(&mm->mmap_sem);
+
+ for ( ; pm->node != MAX_NUMNODES; pm++) {
+ struct vm_area_struct *vma;
+ struct page *page;
+ int err;
+
+ err = -EFAULT;
+ vma = find_vma(mm, pm->addr);
+ if (!vma)
+ goto set_status;
+
+ page = follow_page(vma, pm->addr, 0);
+ err = -ENOENT;
+ /* Use PageReserved to check for zero page */
+ if (!page || PageReserved(page))
+ goto set_status;
+
+ err = page_to_nid(page);
+set_status:
+ pm->status = err;
+ }
+
+ up_read(&mm->mmap_sem);
+ return 0;
+}
+
+/*
* Move a list of pages in the address space of the currently executing
* process.
*/
-asmlinkage long sys_move_pages(int pid, unsigned long nr_pages,
- const unsigned long __user *pages,
+asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
+ const void __user * __user *pages,
const int __user *nodes,
int __user *status, int flags)
{
@@ -759,7 +871,6 @@ asmlinkage long sys_move_pages(int pid,
nodemask_t task_nodes;
struct mm_struct *mm;
struct page_to_node *pm = NULL;
- LIST_HEAD(pagelist);
/* Check flags */
if (flags & ~(MPOL_MF_MOVE|MPOL_MF_MOVE_ALL))
@@ -787,99 +898,64 @@ asmlinkage long sys_move_pages(int pid,
}
task_nodes = cpuset_mems_allowed(task);
- pm = kmalloc(GFP_KERNEL, (nr_pages + 1) * sizeof(struct page_to_node));
+
+ /* Limit nr_pages so that the multiplication may not overflow */
+ if (nr_pages >= ULONG_MAX / sizeof(struct page_to_node) - 1) {
+ err = -E2BIG;
+ goto out2;
+ }
+
+ pm = vmalloc((nr_pages + 1) * sizeof(struct page_to_node));
if (!pm) {
err = -ENOMEM;
goto out2;
}
- down_read(&mm->mmap_sem);
-
- for(i = 0 ; i < nr_pages; i++) {
- unsigned long addr;
- int node;
- struct vm_area_struct *vma;
- struct page *page;
-
- pm[i].page = ZERO_PAGE(0);
+ /*
+ * Get parameters from user space and initialize the pm
+ * array. Return various errors if the user did something wrong.
+ */
+ for (i = 0; i < nr_pages; i++) {
+ const void *p;
err = -EFAULT;
- if (get_user(addr, pages + i))
- goto putback;
-
- vma = find_vma(mm, addr);
- if (!vma)
- goto set_status;
+ if (get_user(p, pages + i))
+ goto out;
- page = follow_page(vma, addr, FOLL_GET);
- err = -ENOENT;
- if (!page)
- goto set_status;
-
- pm[i].page = page;
- if (!nodes) {
- err = page_to_nid(page);
- put_page(page);
- goto set_status;
- }
+ pm[i].addr = (unsigned long)p;
+ if (nodes) {
+ int node;
- err = -EPERM;
- if (page_mapcount(page) > 1 &&
- !(flags & MPOL_MF_MOVE_ALL)) {
- put_page(page);
- goto set_status;
- }
-
-
- err = isolate_lru_page(page, &pagelist);
- __put_page(page);
- if (err)
- goto remove;
-
- err = -EFAULT;
- if (get_user(node, nodes + i))
- goto remove;
-
- err = -ENOENT;
- if (!node_online(node))
- goto remove;
+ if (get_user(node, nodes + i))
+ goto out;
- err = -EPERM;
- if (!node_isset(node, task_nodes))
- goto remove;
+ err = -ENODEV;
+ if (!node_online(node))
+ goto out;
- pm[i].node = node;
- err = -EAGAIN;
- if (node != page_to_nid(page))
- goto set_status;
+ err = -EACCES;
+ if (!node_isset(node, task_nodes))
+ goto out;
- err = node;
-remove:
- list_del(&page->lru);
- move_to_lru(page);
-set_status:
- pm[i].status = err;
+ pm[i].node = node;
+ }
}
- err = 0;
- if (!nodes || list_empty(&pagelist))
- goto out;
+ /* End marker */
+ pm[nr_pages].node = MAX_NUMNODES;
- pm[nr_pages].page = NULL;
-
- err = migrate_pages(&pagelist, new_page_node, (unsigned long)pm);
- goto out;
-
-putback:
- putback_lru_pages(&pagelist);
+ if (nodes)
+ err = do_move_pages(mm, pm, flags & MPOL_MF_MOVE_ALL);
+ else
+ err = do_pages_stat(mm, pm);
-out:
- up_read(&mm->mmap_sem);
if (err >= 0)
/* Return status information */
- for(i = 0; i < nr_pages; i++)
- put_user(pm[i].status, status +i);
+ for (i = 0; i < nr_pages; i++)
+ if (put_user(pm[i].status, status + i))
+ err = -EFAULT;
- kfree(pm);
+out:
+ vfree(pm);
out2:
mmput(mm);
return err;
Index: linux-2.6.17-rc4-mm3/Documentation/vm/page_migration
=================================--- linux-2.6.17-rc4-mm3.orig/Documentation/vm/page_migration 2006-05-22 18:03:26.500852784 -0700
+++ linux-2.6.17-rc4-mm3/Documentation/vm/page_migration 2006-05-23 10:03:36.021003240 -0700
@@ -26,8 +26,13 @@ a process are located. See also the numa
Manual migration is useful if for example the scheduler has relocated a process to a processor on a distant node. A batch scheduler or an administrator may detect the situation and move the pages of the process
-nearer to the new processor. At some point in the future we may have -some mechanism in the scheduler that will automatically move the pages. +nearer to the new processor. The kernel itself does only provide +manual page migration support. Automatic page migration may be implemented +through user space processes that move pages. A special function call +"move_pages" allows the moving of individual pages within a process. +A NUMA profiler may f.e. obtain a log showing frequent off node +accesses and may use the result to move pages to more advantageous +locations.
Larger installations usually partition the system using cpusets into sections of nodes. Paul Jackson has equipped cpusets with the ability to
@@ -62,22 +67,14 @@ A. In kernel use of migrate_pages()
It also prevents the swapper or other scans to encounter the page.
-2. Generate a list of newly allocates pages. These pages will contain the
- contents of the pages from the first list after page migration is
- complete.
+2. We need to have a function of type new_page_t that can be
+ passed to migrate_pages(). This function should figure out
+ how to allocate the correct new page given the old page.
3. The migrate_pages() function is called which attempts
- to do the migration. It returns the moved pages in the - list specified as the third parameter and the failed - migrations in the fourth parameter. When the function - returns the first list will contain the pages that could still be retried. - -4. The leftover pages of various types are returned - to the LRU using putback_to_lru_pages() or otherwise - disposed of. The pages will still have the refcount as - increased by isolate_lru_pages() if putback_to_lru_pages() is not - used! The kernel may want to handle the various cases of failures in - different ways. + to do the migration. It will call the function to allocate + the new page for each page that is considered for + moving.
B. How migrate_pages() works
----------------------------
Index: linux-2.6.17-rc4-mm3/include/linux/syscalls.h
=================================--- linux-2.6.17-rc4-mm3.orig/include/linux/syscalls.h 2006-05-22 18:03:31.876495496 -0700
+++ linux-2.6.17-rc4-mm3/include/linux/syscalls.h 2006-05-23 10:03:36.022956244 -0700
@@ -515,6 +515,11 @@ asmlinkage long sys_set_mempolicy(int mo
asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
const unsigned long __user *from, const unsigned long __user *to);
+asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
+ const void __user * __user *pages,
+ const int __user *nodes,
+ int __user *status,
+ int flags);
asmlinkage long sys_mbind(unsigned long start, unsigned long len,
unsigned long mode, unsigned long __user *nmask,
PATCH 4/5 move_pages: x86_64 support
In reply to Christoph Lametersys_move_pages support for x86_64
Only compile-tested.
Index: linux-2.6.17-rc4-mm1/include/asm-x86_64/unistd.h
=================================--- linux-2.6.17-rc4-mm1.orig/include/asm-x86_64/unistd.h 2006-05-21 00:18:04.000000000 +1000
+++ linux-2.6.17-rc4-mm1/include/asm-x86_64/unistd.h 2006-05-21 00:19:33.000000000 +1000
@@ -617,10 +617,12 @@
__SYSCALL(__NR_sync_file_range, sys_sync_file_range)
#define __NR_vmsplice 278
__SYSCALL(__NR_vmsplice, sys_vmsplice)
+#define __NR_move_pages 279
+__SYSCALL(__NR_move_pages, sys_move_pages)
#ifdef __KERNEL__
-#define __NR_syscall_max __NR_vmsplice
+#define __NR_syscall_max __NR_move_pages
#ifndef __NO_STUBS
PATCH 5/5 move_pages: 32bit support (i386,x86_64 and ia64)
In reply to Christoph Lametersys_move_pages() support for 32bit (i386 plus ia64 and x86_64 compat layers)
Add support for move_pages() on i386 and also add the compat functions necessary to run 32 bit binaries on x86_64 and ia64.
Add compat_sys_move_pages to both the x86_64 and the ia64 32bit binary layer. Note that both are not up to date so I added the missing pieces. Not sure if this is done the right way.
This probably needs some fixups:
1. What about sys_vmsplice on x86_64?
2. There is a whole range of syscalls missing for ia64 that I basically interpolated from elsewhere.
Index: linux-2.6.17-rc4-mm3/arch/i386/kernel/syscall_table.S
=================================--- linux-2.6.17-rc4-mm3.orig/arch/i386/kernel/syscall_table.S 2006-05-11 16:31:53.000000000 -0700
+++ linux-2.6.17-rc4-mm3/arch/i386/kernel/syscall_table.S 2006-05-23 10:15:43.789358191 -0700
@@ -315,3 +315,5 @@ ENTRY(sys_call_table)
.long sys_splice
.long sys_sync_file_range
.long sys_tee /* 315 */
+ .long sys_ni_syscall /* vmsplice */
+ .long sys_move_pages
Index: linux-2.6.17-rc4-mm3/arch/x86_64/ia32/ia32entry.S
=================================--- linux-2.6.17-rc4-mm3.orig/arch/x86_64/ia32/ia32entry.S 2006-05-22 18:03:26.298716900 -0700
+++ linux-2.6.17-rc4-mm3/arch/x86_64/ia32/ia32entry.S 2006-05-23 10:15:43.791311196 -0700
@@ -699,4 +699,5 @@ ia32_sys_call_table:
.quad sys_sync_file_range
.quad sys_tee
.quad compat_sys_vmsplice
+ .quad compat_sys_move_pages
ia32_syscall_end:
Index: linux-2.6.17-rc4-mm3/include/asm-i386/unistd.h
=================================--- linux-2.6.17-rc4-mm3.orig/include/asm-i386/unistd.h 2006-05-22 18:03:30.090473603 -0700
+++ linux-2.6.17-rc4-mm3/include/asm-i386/unistd.h 2006-05-23 10:15:43.792287698 -0700
@@ -322,10 +322,11 @@
#define __NR_sync_file_range 314
#define __NR_tee 315
#define __NR_vmsplice 316
+#define __NR_move_pages 317
#ifdef __KERNEL__
-#define NR_syscalls 317
+#define NR_syscalls 318
/*
* user-visible error numbers are in the range -1 - -128: see
Index: linux-2.6.17-rc4-mm3/kernel/compat.c
=================================--- linux-2.6.17-rc4-mm3.orig/kernel/compat.c 2006-05-11 16:31:53.000000000 -0700
+++ linux-2.6.17-rc4-mm3/kernel/compat.c 2006-05-23 10:15:43.793264200 -0700
@@ -21,6 +21,7 @@
#include <linux/unistd.h>
#include <linux/security.h>
#include <linux/timex.h>
+#include <linux/migrate.h>
#include <asm/uaccess.h>
@@ -934,3 +935,25 @@ asmlinkage long compat_sys_adjtimex(stru
return ret;
}
+
+#ifdef CONFIG_NUMA
+asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
+ void __user *pages32,
+ const int __user *nodes,
+ int __user *status,
+ int flags)
+{
+ const void __user * __user *pages;
+ int i;
+
+ pages = compat_alloc_user_space(nr_pages * sizeof(void *));
+ for (i = 0; i < nr_pages; i++) {
+ compat_uptr_t p;
+
+ if (get_user(p, (compat_uptr_t *)(pages32 + i)) ||
+ put_user(compat_ptr(p), pages + i))
+ return -EFAULT;
+ }
+ return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
+}
+#endif
Index: linux-2.6.17-rc4-mm3/include/linux/syscalls.h
=================================--- linux-2.6.17-rc4-mm3.orig/include/linux/syscalls.h 2006-05-23 10:03:36.022956244 -0700
+++ linux-2.6.17-rc4-mm3/include/linux/syscalls.h 2006-05-23 10:15:43.794240702 -0700
@@ -520,6 +520,11 @@ asmlinkage long sys_move_pages(pid_t pid
const int __user *nodes,
int __user *status,
int flags);
+asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
+ void __user *pages,
+ const int __user *nodes,
+ int __user *status,
+ int flags);
asmlinkage long sys_mbind(unsigned long start, unsigned long len,
unsigned long mode,
unsigned long __user *nmask,
Index: linux-2.6.17-rc4-mm3/arch/ia64/ia32/ia32_entry.S
=================================--- linux-2.6.17-rc4-mm3.orig/arch/ia64/ia32/ia32_entry.S 2006-05-11 16:31:53.000000000 -0700
+++ linux-2.6.17-rc4-mm3/arch/ia64/ia32/ia32_entry.S 2006-05-23 10:15:43.796193706 -0700
@@ -495,6 +495,39 @@ ia32_syscall_table:
data8 compat_sys_mq_getsetattr
data8 sys_ni_syscall /* reserved for kexec */
data8 compat_sys_waitid
+ data8 sys_ni_syscall /* 285: sys_altroot */
+ data8 sys_add_key
+ data8 sys_request_key
+ data8 sys_keyctl
+ data8 sys_ioprio_set
+ data8 sys_ioprio_get /* 290 */
+ data8 sys_inotify_init
+ data8 sys_inotify_add_watch
+ data8 sys_inotify_rm_watch
+ data8 sys_migrate_pages
+ data8 compat_sys_openat /* 295 */
+ data8 sys_mkdirat
+ data8 sys_mknodat
+ data8 sys_fchownat
+ data8 compat_sys_futimesat
+ data8 sys_ni_syscall /* broken: sys_fstatat 300 */
+ data8 sys_unlinkat
+ data8 sys_renameat
+ data8 sys_linkat
+ data8 sys_symlinkat
+ data8 sys_readlinkat /* 305 */
+ data8 sys_fchmodat
+ data8 sys_faccessat
+ data8 sys_ni_syscall /* pselect6 */
+ data8 sys_ni_syscall /* ppoll */
+ data8 sys_unshare /* 310 */
+ data8 compat_sys_set_robust_list
+ data8 compat_sys_get_robust_list
+ data8 sys_splice
+ data8 sys_sync_file_range
+ data8 sys_tee /* 315 */
+ data8 compat_sys_vmsplice
+ data8 compat_sys_move_pages
// guard against failures to increase IA32_NR_syscalls .org ia32_syscall_table + 8*IA32_NR_syscalls
Index: linux-2.6.17-rc4-mm3/include/asm-ia64/ia32.h
=================================--- linux-2.6.17-rc4-mm3.orig/include/asm-ia64/ia32.h 2006-05-22 18:03:30.107074135 -0700
+++ linux-2.6.17-rc4-mm3/include/asm-ia64/ia32.h 2006-05-23 10:15:43.796193706 -0700
@@ -5,7 +5,7 @@
#include <asm/ptrace.h>
#include <asm/signal.h>
-#define IA32_NR_syscalls 285 /* length of syscall table */
+#define IA32_NR_syscalls 318 /* length of syscall table */
#define IA32_PAGE_SHIFT 12 /* 4KB pages */
#ifndef __ASSEMBLY__
Re: [5/5] move_pages: 32bit support (i386,x86_64 and ia64)
Quoted 10 lines · Christoph Lameter
sys_move_pages()support for 32bit (i386 plus ia64 andx86_64compat layers)Add support for
move_pages()on i386 and also add the compat functions necessary to run 32 bit binaries onx86_64and ia64.Add
compat_sys_move_pagesto both thex86_64and the ia64 32bit binary layer. Note that both are not up to date so I added the missing pieces. Not sure if this is done the right way.
Quoted 6 lines
This probably needs some fixups:
1. What about
sys_vmspliceonx86_64?2. There is a whole range of syscalls missing for ia64 that I basically interpolated from elsewhere.
I dropped the ia64 bits - looks like that's all on death row anyway.
The omission of sys_vmsplice() from the x86 syscall table does appear to be, umm, a glaring omission. Jens, what's up?
Re: [5/5] move_pages: 32bit support (i386,x86_64 and ia64)
Quoted 15 lines · Andrew Morton
Quoted 14 lines · Christoph Lameter
sys_move_pages()support for 32bit (i386 plus ia64 andx86_64compat layers)Add support for
move_pages()on i386 and also add the compat functions necessary to run 32 bit binaries onx86_64and ia64.Add
compat_sys_move_pagesto both thex86_64and the ia64 32bit binary layer. Note that both are not up to date so I added the missing pieces. Not sure if this is done the right way.This probably needs some fixups:
1. What about
sys_vmspliceonx86_64?
Quoted 7 lines
Quoted 2 lines
2. There is a whole range of syscalls missing for ia64 that I basically interpolated from elsewhere.
I dropped the ia64 bits - looks like that's all on death row anyway.
The omission of
sys_vmsplice()from the x86 syscall table does appear to be, umm, a glaring omission. Jens, what's up?
Uhm yes...
[PATCH] Add vmsplice syscall to x86 table
arch/i386/kernel/syscall_table.S +1 -0
@@ -315,3 +315,4 @@ ENTRY(sys_call_table) .long sys_splice .long sys_sync_file_range .long sys_tee /* 315 */ + .long sys_vmsplice
Signature · 1 line
Jens Axboe