aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugh Dickins <hugh@veritas.com>2005-11-22 00:32:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-22 12:13:42 -0500
commitf57e88a8d83de8d844b57e16b84d2f762fe9f092 (patch)
tree32fee3ab5c177bc0f47827dd18ad4471be3b2a74
parentee498ed730283e9cdfc8913f12b90a2246f1a8cc (diff)
[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>
-rw-r--r--drivers/char/mem.c2
-rw-r--r--mm/memory.c14
2 files changed, 13 insertions, 3 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 91dd669273e0..29c3b631445a 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -591,7 +591,7 @@ static inline size_t read_zero_pagealigned(char __user * buf, size_t size)
591 591
592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0) 592 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0)
593 goto out_up; 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 break; 595 break;
596 count = vma->vm_end - addr; 596 count = vma->vm_end - addr;
597 if (count > size) 597 if (count > size)
diff --git a/mm/memory.c b/mm/memory.c
index 3666a4c6dd22..d1f46f4e4c8a 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1812,7 +1812,16 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
1812 spinlock_t *ptl; 1812 spinlock_t *ptl;
1813 pte_t entry; 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 /* Allocate our own private page. */ 1825 /* Allocate our own private page. */
1817 pte_unmap(page_table); 1826 pte_unmap(page_table);
1818 1827
@@ -1887,6 +1896,7 @@ static int do_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
1887 int anon = 0; 1896 int anon = 0;
1888 1897
1889 pte_unmap(page_table); 1898 pte_unmap(page_table);
1899 BUG_ON(vma->vm_flags & VM_UNPAGED);
1890 1900
1891 if (vma->vm_file) { 1901 if (vma->vm_file) {
1892 mapping = vma->vm_file->f_mapping; 1902 mapping = vma->vm_file->f_mapping;
@@ -1962,7 +1972,7 @@ retry:
1962 inc_mm_counter(mm, anon_rss); 1972 inc_mm_counter(mm, anon_rss);
1963 lru_cache_add_active(new_page); 1973 lru_cache_add_active(new_page);
1964 page_add_anon_rmap(new_page, vma, address); 1974 page_add_anon_rmap(new_page, vma, address);
1965 } else if (!(vma->vm_flags & VM_UNPAGED)) { 1975 } else {
1966 inc_mm_counter(mm, file_rss); 1976 inc_mm_counter(mm, file_rss);
1967 page_add_file_rmap(new_page); 1977 page_add_file_rmap(new_page);
1968 } 1978 }