Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186201
b: refs/heads/master
c: 9d8cebd
h: refs/heads/master
i:
  186199: db3691c
v: v3
  • Loading branch information
KOSAKI Motohiro authored and Linus Torvalds committed Mar 6, 2010
1 parent fd97aba commit 15116d4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 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: 93e4a89a8c987189b168a530a331ef6d0fcf07a7
refs/heads/master: 9d8cebd4bcd7c3878462fdfda34bbcdeb4df7ef4
52 changes: 39 additions & 13 deletions trunk/mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,24 +563,50 @@ static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new)
}

/* Step 2: apply policy to a range and do splits. */
static int mbind_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct mempolicy *new)
static int mbind_range(struct mm_struct *mm, unsigned long start,
unsigned long end, struct mempolicy *new_pol)
{
struct vm_area_struct *next;
int err;
struct vm_area_struct *prev;
struct vm_area_struct *vma;
int err = 0;
pgoff_t pgoff;
unsigned long vmstart;
unsigned long vmend;

err = 0;
for (; vma && vma->vm_start < end; vma = next) {
vma = find_vma_prev(mm, start, &prev);
if (!vma || vma->vm_start > start)
return -EFAULT;

for (; vma && vma->vm_start < end; prev = vma, vma = next) {
next = vma->vm_next;
if (vma->vm_start < start)
err = split_vma(vma->vm_mm, vma, start, 1);
if (!err && vma->vm_end > end)
err = split_vma(vma->vm_mm, vma, end, 0);
if (!err)
err = policy_vma(vma, new);
vmstart = max(start, vma->vm_start);
vmend = min(end, vma->vm_end);

pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
vma->anon_vma, vma->vm_file, pgoff, new_pol);
if (prev) {
vma = prev;
next = vma->vm_next;
continue;
}
if (vma->vm_start != vmstart) {
err = split_vma(vma->vm_mm, vma, vmstart, 1);
if (err)
goto out;
}
if (vma->vm_end != vmend) {
err = split_vma(vma->vm_mm, vma, vmend, 0);
if (err)
goto out;
}
err = policy_vma(vma, new_pol);
if (err)
break;
goto out;
}

out:
return err;
}

Expand Down Expand Up @@ -1047,7 +1073,7 @@ static long do_mbind(unsigned long start, unsigned long len,
if (!IS_ERR(vma)) {
int nr_failed = 0;

err = mbind_range(vma, start, end, new);
err = mbind_range(mm, start, end, new);

if (!list_empty(&pagelist))
nr_failed = migrate_pages(&pagelist, new_vma_page,
Expand Down

0 comments on commit 15116d4

Please sign in to comment.