Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332351
b: refs/heads/master
c: 869833f
h: refs/heads/master
i:
  332349: baf7031
  332347: 3fbd789
  332343: de7410c
  332335: 08af4a2
  332319: 8795331
  332287: 165ffa9
v: v3
  • Loading branch information
KOSAKI Motohiro authored and Linus Torvalds committed Oct 9, 2012
1 parent 2e8751f commit a62a70c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 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: 8d34694c1abf29df1f3c7317936b7e3e2e308d9b
refs/heads/master: 869833f2c5c6e4dd09a5378cfc665ffb4615e5d2
52 changes: 38 additions & 14 deletions trunk/mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,24 +607,39 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
return first;
}

/* Apply policy to a single VMA */
static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new)
/*
* Apply policy to a single VMA
* This must be called with the mmap_sem held for writing.
*/
static int vma_replace_policy(struct vm_area_struct *vma,
struct mempolicy *pol)
{
int err = 0;
struct mempolicy *old = vma->vm_policy;
int err;
struct mempolicy *old;
struct mempolicy *new;

pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
vma->vm_start, vma->vm_end, vma->vm_pgoff,
vma->vm_ops, vma->vm_file,
vma->vm_ops ? vma->vm_ops->set_policy : NULL);

if (vma->vm_ops && vma->vm_ops->set_policy)
new = mpol_dup(pol);
if (IS_ERR(new))
return PTR_ERR(new);

if (vma->vm_ops && vma->vm_ops->set_policy) {
err = vma->vm_ops->set_policy(vma, new);
if (!err) {
mpol_get(new);
vma->vm_policy = new;
mpol_put(old);
if (err)
goto err_out;
}

old = vma->vm_policy;
vma->vm_policy = new; /* protected by mmap_sem */
mpol_put(old);

return 0;
err_out:
mpol_put(new);
return err;
}

Expand Down Expand Up @@ -676,7 +691,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
if (err)
goto out;
}
err = policy_vma(vma, new_pol);
err = vma_replace_policy(vma, new_pol);
if (err)
goto out;
}
Expand Down Expand Up @@ -2153,15 +2168,24 @@ static void sp_delete(struct shared_policy *sp, struct sp_node *n)
static struct sp_node *sp_alloc(unsigned long start, unsigned long end,
struct mempolicy *pol)
{
struct sp_node *n = kmem_cache_alloc(sn_cache, GFP_KERNEL);
struct sp_node *n;
struct mempolicy *newpol;

n = kmem_cache_alloc(sn_cache, GFP_KERNEL);
if (!n)
return NULL;

newpol = mpol_dup(pol);
if (IS_ERR(newpol)) {
kmem_cache_free(sn_cache, n);
return NULL;
}
newpol->flags |= MPOL_F_SHARED;

n->start = start;
n->end = end;
mpol_get(pol);
pol->flags |= MPOL_F_SHARED; /* for unref */
n->policy = pol;
n->policy = newpol;

return n;
}

Expand Down

0 comments on commit a62a70c

Please sign in to comment.