Commit 72866f6f authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] mm: anon is already wrprotected

do_anonymous_page's pte_wrprotect causes some confusion: in such a case,
vm_page_prot must already be forcing COW, so must omit write permission, and
so the pte_wrprotect is redundant.  Replace it by a comment to that effect,
and reword the comment on unuse_pte which also caused confusion.
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6237bcd9
...@@ -1768,13 +1768,14 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -1768,13 +1768,14 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long addr) unsigned long addr)
{ {
pte_t entry; pte_t entry;
struct page * page = ZERO_PAGE(addr);
/* Read-only mapping of ZERO_PAGE. */ /* Mapping of ZERO_PAGE - vm_page_prot is readonly */
entry = pte_wrprotect(mk_pte(ZERO_PAGE(addr), vma->vm_page_prot)); entry = mk_pte(ZERO_PAGE(addr), vma->vm_page_prot);
/* ..except if it's a write access */ /* ..except if it's a write access */
if (write_access) { if (write_access) {
struct page *page;
/* Allocate our own private page. */ /* Allocate our own private page. */
pte_unmap(page_table); pte_unmap(page_table);
spin_unlock(&mm->page_table_lock); spin_unlock(&mm->page_table_lock);
......
...@@ -398,10 +398,9 @@ void free_swap_and_cache(swp_entry_t entry) ...@@ -398,10 +398,9 @@ void free_swap_and_cache(swp_entry_t entry)
} }
/* /*
* Always set the resulting pte to be nowrite (the same as COW pages * No need to decide whether this PTE shares the swap entry with others,
* after one process has exited). We don't know just how many PTEs will * just let do_wp_page work it out if a write is requested later - to
* share this swap entry, so be cautious and let do_wp_page work out * force COW, vm_page_prot omits write permission from any private vma.
* what to do if a write is requested later.
* *
* vma->vm_mm->page_table_lock is held. * vma->vm_mm->page_table_lock is held.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment