[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 591 592 592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0) 593 593 goto out_up; 594 - if (vma->vm_flags & (VM_SHARED | VM_HUGETLB)) 594 + if (vma->vm_flags & (VM_SHARED | VM_HUGETLB | VM_UNPAGED)) 595 595 break; 596 596 count = vma->vm_end - addr; 597 597 if (count > size)
+12 -2
mm/memory.c
··· 1812 1812 spinlock_t *ptl; 1813 1813 pte_t entry; 1814 1814 1815 - if (write_access) { 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)) { 1816 1825 /* Allocate our own private page. */ 1817 1826 pte_unmap(page_table); 1818 1827 ··· 1896 1887 int anon = 0; 1897 1888 1898 1889 pte_unmap(page_table); 1890 + BUG_ON(vma->vm_flags & VM_UNPAGED); 1899 1891 1900 1892 if (vma->vm_file) { 1901 1893 mapping = vma->vm_file->f_mapping; ··· 1972 1962 inc_mm_counter(mm, anon_rss); 1973 1963 lru_cache_add_active(new_page); 1974 1964 page_add_anon_rmap(new_page, vma, address); 1975 - } else if (!(vma->vm_flags & VM_UNPAGED)) { 1965 + } else { 1976 1966 inc_mm_counter(mm, file_rss); 1977 1967 page_add_file_rmap(new_page); 1978 1968 }