aboutsummaryrefslogtreecommitdiffstats
path: root/mm/rmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/rmap.c')
-rw-r--r--mm/rmap.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/mm/rmap.c b/mm/rmap.c
index 914d04b98bee..2e034a0b89ab 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -225,7 +225,9 @@ vma_address(struct page *page, struct vm_area_struct *vma)
225 225
226/* 226/*
227 * At what user virtual address is page expected in vma? checking that the 227 * At what user virtual address is page expected in vma? checking that the
228 * page matches the vma: currently only used by unuse_process, on anon pages. 228 * page matches the vma: currently only used on anon pages, by unuse_vma;
229 * and by extraordinary checks on anon pages in VM_UNPAGED vmas, taking
230 * care that an mmap of /dev/mem might window free and foreign pages.
229 */ 231 */
230unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma) 232unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
231{ 233{
@@ -234,7 +236,8 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
234 (void *)page->mapping - PAGE_MAPPING_ANON) 236 (void *)page->mapping - PAGE_MAPPING_ANON)
235 return -EFAULT; 237 return -EFAULT;
236 } else if (page->mapping && !(vma->vm_flags & VM_NONLINEAR)) { 238 } else if (page->mapping && !(vma->vm_flags & VM_NONLINEAR)) {
237 if (vma->vm_file->f_mapping != page->mapping) 239 if (!vma->vm_file ||
240 vma->vm_file->f_mapping != page->mapping)
238 return -EFAULT; 241 return -EFAULT;
239 } else 242 } else
240 return -EFAULT; 243 return -EFAULT;
@@ -529,10 +532,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
529 * If the page is mlock()d, we cannot swap it out. 532 * If the page is mlock()d, we cannot swap it out.
530 * If it's recently referenced (perhaps page_referenced 533 * If it's recently referenced (perhaps page_referenced
531 * skipped over this mm) then we should reactivate it. 534 * skipped over this mm) then we should reactivate it.
532 *
533 * Pages belonging to VM_RESERVED regions should not happen here.
534 */ 535 */
535 if ((vma->vm_flags & (VM_LOCKED|VM_RESERVED)) || 536 if ((vma->vm_flags & VM_LOCKED) ||
536 ptep_clear_flush_young(vma, address, pte)) { 537 ptep_clear_flush_young(vma, address, pte)) {
537 ret = SWAP_FAIL; 538 ret = SWAP_FAIL;
538 goto out_unmap; 539 goto out_unmap;
@@ -727,7 +728,7 @@ static int try_to_unmap_file(struct page *page)
727 728
728 list_for_each_entry(vma, &mapping->i_mmap_nonlinear, 729 list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
729 shared.vm_set.list) { 730 shared.vm_set.list) {
730 if (vma->vm_flags & (VM_LOCKED|VM_RESERVED)) 731 if (vma->vm_flags & VM_LOCKED)
731 continue; 732 continue;
732 cursor = (unsigned long) vma->vm_private_data; 733 cursor = (unsigned long) vma->vm_private_data;
733 if (cursor > max_nl_cursor) 734 if (cursor > max_nl_cursor)
@@ -761,7 +762,7 @@ static int try_to_unmap_file(struct page *page)
761 do { 762 do {
762 list_for_each_entry(vma, &mapping->i_mmap_nonlinear, 763 list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
763 shared.vm_set.list) { 764 shared.vm_set.list) {
764 if (vma->vm_flags & (VM_LOCKED|VM_RESERVED)) 765 if (vma->vm_flags & VM_LOCKED)
765 continue; 766 continue;
766 cursor = (unsigned long) vma->vm_private_data; 767 cursor = (unsigned long) vma->vm_private_data;
767 while ( cursor < max_nl_cursor && 768 while ( cursor < max_nl_cursor &&
@@ -783,11 +784,8 @@ static int try_to_unmap_file(struct page *page)
783 * in locked vmas). Reset cursor on all unreserved nonlinear 784 * in locked vmas). Reset cursor on all unreserved nonlinear
784 * vmas, now forgetting on which ones it had fallen behind. 785 * vmas, now forgetting on which ones it had fallen behind.
785 */ 786 */
786 list_for_each_entry(vma, &mapping->i_mmap_nonlinear, 787 list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list)
787 shared.vm_set.list) { 788 vma->vm_private_data = NULL;
788 if (!(vma->vm_flags & VM_RESERVED))
789 vma->vm_private_data = NULL;
790 }
791out: 789out:
792 spin_unlock(&mapping->i_mmap_lock); 790 spin_unlock(&mapping->i_mmap_lock);
793 return ret; 791 return ret;