Commit 8d34694c1abf29df1f3c7317936b7e3e2e308d9b

Authored by KOSAKI Motohiro
Committed by Linus Torvalds
1 parent 1fb3f8ca0e

revert "mm: mempolicy: Let vma_merge and vma_split handle vma->vm_policy linkages"

Commit 05f144a0d5c2 ("mm: mempolicy: Let vma_merge and vma_split handle
vma->vm_policy linkages") removed vma->vm_policy updates code but it is
the purpose of mbind_range().  Now, mbind_range() is virtually a no-op
and while it does not allow memory corruption it is not the right fix.
This patch is a revert.

[mgorman@suse.de: Edited changelog]
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Cc: Christoph Lameter <cl@linux.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 24 additions and 17 deletions Side-by-side Diff

... ... @@ -607,6 +607,27 @@
607 607 return first;
608 608 }
609 609  
  610 +/* Apply policy to a single VMA */
  611 +static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new)
  612 +{
  613 + int err = 0;
  614 + struct mempolicy *old = vma->vm_policy;
  615 +
  616 + pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
  617 + vma->vm_start, vma->vm_end, vma->vm_pgoff,
  618 + vma->vm_ops, vma->vm_file,
  619 + vma->vm_ops ? vma->vm_ops->set_policy : NULL);
  620 +
  621 + if (vma->vm_ops && vma->vm_ops->set_policy)
  622 + err = vma->vm_ops->set_policy(vma, new);
  623 + if (!err) {
  624 + mpol_get(new);
  625 + vma->vm_policy = new;
  626 + mpol_put(old);
  627 + }
  628 + return err;
  629 +}
  630 +
610 631 /* Step 2: apply policy to a range and do splits. */
611 632 static int mbind_range(struct mm_struct *mm, unsigned long start,
612 633 unsigned long end, struct mempolicy *new_pol)
... ... @@ -655,23 +676,9 @@
655 676 if (err)
656 677 goto out;
657 678 }
658   -
659   - /*
660   - * Apply policy to a single VMA. The reference counting of
661   - * policy for vma_policy linkages has already been handled by
662   - * vma_merge and split_vma as necessary. If this is a shared
663   - * policy then ->set_policy will increment the reference count
664   - * for an sp node.
665   - */
666   - pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
667   - vma->vm_start, vma->vm_end, vma->vm_pgoff,
668   - vma->vm_ops, vma->vm_file,
669   - vma->vm_ops ? vma->vm_ops->set_policy : NULL);
670   - if (vma->vm_ops && vma->vm_ops->set_policy) {
671   - err = vma->vm_ops->set_policy(vma, new_pol);
672   - if (err)
673   - goto out;
674   - }
  679 + err = policy_vma(vma, new_pol);
  680 + if (err)
  681 + goto out;
675 682 }
676 683  
677 684 out: