Skip to content

Commit 72866f6

Browse files
Hugh DickinsLinus Torvalds
authored andcommitted
[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: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 6237bcd commit 72866f6

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎mm/memory.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,13 +1768,14 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
17681768
unsigned long addr)
17691769
{
17701770
pte_t entry;
1771-
struct page * page = ZERO_PAGE(addr);
17721771

1773-
/* Read-only mapping of ZERO_PAGE. */
1774-
entry = pte_wrprotect(mk_pte(ZERO_PAGE(addr), vma->vm_page_prot));
1772+
/* Mapping of ZERO_PAGE - vm_page_prot is readonly */
1773+
entry = mk_pte(ZERO_PAGE(addr), vma->vm_page_prot);
17751774

17761775
/* ..except if it's a write access */
17771776
if (write_access) {
1777+
struct page *page;
1778+
17781779
/* Allocate our own private page. */
17791780
pte_unmap(page_table);
17801781
spin_unlock(&mm->page_table_lock);

‎mm/swapfile.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,9 @@ void free_swap_and_cache(swp_entry_t entry)
398398
}
399399

400400
/*
401-
* Always set the resulting pte to be nowrite (the same as COW pages
402-
* after one process has exited). We don't know just how many PTEs will
403-
* share this swap entry, so be cautious and let do_wp_page work out
404-
* what to do if a write is requested later.
401+
* No need to decide whether this PTE shares the swap entry with others,
402+
* just let do_wp_page work it out if a write is requested later - to
403+
* force COW, vm_page_prot omits write permission from any private vma.
405404
*
406405
* vma->vm_mm->page_table_lock is held.
407406
*/

0 commit comments

Comments
 (0)