Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115877
b: refs/heads/master
c: 2f007e7
h: refs/heads/master
i:
  115875: 8266ece
v: v3
  • Loading branch information
Brice Goglin authored and Linus Torvalds committed Oct 20, 2008
1 parent 6bb7b2c commit c20b3bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e78bbfa8262424417a29349a8064a535053912b9
refs/heads/master: 2f007e74bb85b9fc4eab28524052161703300f1a
40 changes: 25 additions & 15 deletions trunk/mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,25 +906,33 @@ static int do_move_pages(struct mm_struct *mm, struct page_to_node *pm,
}

/*
* 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.
* Determine the nodes of an array of pages and store it in an array of status.
*/
static int do_pages_stat(struct mm_struct *mm, struct page_to_node *pm)
static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
const void __user * __user *pages,
int __user *status)
{
unsigned long i;
int err;

down_read(&mm->mmap_sem);

for ( ; pm->node != MAX_NUMNODES; pm++) {
for (i = 0; i < nr_pages; i++) {
const void __user *p;
unsigned long addr;
struct vm_area_struct *vma;
struct page *page;
int err;

err = -EFAULT;
vma = find_vma(mm, pm->addr);
if (get_user(p, pages+i))
goto out;
addr = (unsigned long) p;

vma = find_vma(mm, addr);
if (!vma)
goto set_status;

page = follow_page(vma, pm->addr, 0);
page = follow_page(vma, addr, 0);

err = PTR_ERR(page);
if (IS_ERR(page))
Expand All @@ -937,11 +945,13 @@ static int do_pages_stat(struct mm_struct *mm, struct page_to_node *pm)

err = page_to_nid(page);
set_status:
pm->status = err;
put_user(err, status+i);
}
err = 0;

out:
up_read(&mm->mmap_sem);
return 0;
return err;
}

/*
Expand Down Expand Up @@ -997,6 +1007,10 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
if (err)
goto out2;

if (!nodes) {
err = do_pages_stat(mm, nr_pages, pages, status);
goto out2;
}

task_nodes = cpuset_mems_allowed(task);

Expand Down Expand Up @@ -1045,11 +1059,7 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
/* End marker */
pm[nr_pages].node = MAX_NUMNODES;

if (nodes)
err = do_move_pages(mm, pm, flags & MPOL_MF_MOVE_ALL);
else
err = do_pages_stat(mm, pm);

err = do_move_pages(mm, pm, flags & MPOL_MF_MOVE_ALL);
if (err >= 0)
/* Return status information */
for (i = 0; i < nr_pages; i++)
Expand Down

0 comments on commit c20b3bf

Please sign in to comment.