[PATCH] unpaged: ZERO_PAGE in VM_UNPAGED

It's strange enough to be looking out for anonymous pages in VM_UNPAGED areas,
let's not insert the ZERO_PAGE there - though whether it would matter will
depend on what we decide about ZERO_PAGE refcounting.

But whereas do_anonymous_page may (exceptionally) be called on a VM_UNPAGED
area, do_no_page should never be: just BUG_ON.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Hugh Dickins and committed by Linus Torvalds f57e88a8 ee498ed7

+13 -3
+1 -1
drivers/char/mem.c
··· 591 592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0) 593 goto out_up; 594 - if (vma->vm_flags & (VM_SHARED | VM_HUGETLB)) 595 break; 596 count = vma->vm_end - addr; 597 if (count > size)
··· 591 592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0) 593 goto out_up; 594 + if (vma->vm_flags & (VM_SHARED | VM_HUGETLB | VM_UNPAGED)) 595 break; 596 count = vma->vm_end - addr; 597 if (count > size)
+12 -2
mm/memory.c
··· 1812 spinlock_t *ptl; 1813 pte_t entry; 1814 1815 - if (write_access) { 1816 /* Allocate our own private page. */ 1817 pte_unmap(page_table); 1818 ··· 1896 int anon = 0; 1897 1898 pte_unmap(page_table); 1899 1900 if (vma->vm_file) { 1901 mapping = vma->vm_file->f_mapping; ··· 1972 inc_mm_counter(mm, anon_rss); 1973 lru_cache_add_active(new_page); 1974 page_add_anon_rmap(new_page, vma, address); 1975 - } else if (!(vma->vm_flags & VM_UNPAGED)) { 1976 inc_mm_counter(mm, file_rss); 1977 page_add_file_rmap(new_page); 1978 }
··· 1812 spinlock_t *ptl; 1813 pte_t entry; 1814 1815 + /* 1816 + * A VM_UNPAGED vma will normally be filled with present ptes 1817 + * by remap_pfn_range, and never arrive here; but it might have 1818 + * holes, or if !VM_DONTEXPAND, mremap might have expanded it. 1819 + * It's weird enough handling anon pages in unpaged vmas, we do 1820 + * not want to worry about ZERO_PAGEs too (it may or may not 1821 + * matter if their counts wrap): just give them anon pages. 1822 + */ 1823 + 1824 + if (write_access || (vma->vm_flags & VM_UNPAGED)) { 1825 /* Allocate our own private page. */ 1826 pte_unmap(page_table); 1827 ··· 1887 int anon = 0; 1888 1889 pte_unmap(page_table); 1890 + BUG_ON(vma->vm_flags & VM_UNPAGED); 1891 1892 if (vma->vm_file) { 1893 mapping = vma->vm_file->f_mapping; ··· 1962 inc_mm_counter(mm, anon_rss); 1963 lru_cache_add_active(new_page); 1964 page_add_anon_rmap(new_page, vma, address); 1965 + } else { 1966 inc_mm_counter(mm, file_rss); 1967 page_add_file_rmap(new_page); 1968 }