Commit 701dfbc1 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] mm: mremap correct rmap accounting

Nick Piggin points out that page accounting on MIPS multiple ZERO_PAGEs
is not maintained by its move_pte, and could lead to freeing a ZERO_PAGE.

Instead of complicating that move_pte, just forget the minor optimization
when mremapping, and change the one thing which needed it for correctness
- filemap_xip use ZERO_PAGE(0) throughout instead of according to address.

[ "There is no block device driver one could use for XIP on mips
   platforms" - Carsten Otte ]
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Andrew Morton <akpm@osdl.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8339f000
...@@ -69,16 +69,6 @@ extern unsigned long zero_page_mask; ...@@ -69,16 +69,6 @@ extern unsigned long zero_page_mask;
#define ZERO_PAGE(vaddr) \ #define ZERO_PAGE(vaddr) \
(virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))) (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
#define __HAVE_ARCH_MOVE_PTE
#define move_pte(pte, prot, old_addr, new_addr) \
({ \
pte_t newpte = (pte); \
if (pte_present(pte) && pfn_valid(pte_pfn(pte)) && \
pte_page(pte) == ZERO_PAGE(old_addr)) \
newpte = mk_pte(ZERO_PAGE(new_addr), (prot)); \
newpte; \
})
extern void paging_init(void); extern void paging_init(void);
/* /*
......
...@@ -183,7 +183,7 @@ __xip_unmap (struct address_space * mapping, ...@@ -183,7 +183,7 @@ __xip_unmap (struct address_space * mapping,
address = vma->vm_start + address = vma->vm_start +
((pgoff - vma->vm_pgoff) << PAGE_SHIFT); ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
BUG_ON(address < vma->vm_start || address >= vma->vm_end); BUG_ON(address < vma->vm_start || address >= vma->vm_end);
page = ZERO_PAGE(address); page = ZERO_PAGE(0);
pte = page_check_address(page, mm, address, &ptl); pte = page_check_address(page, mm, address, &ptl);
if (pte) { if (pte) {
/* Nuke the page table entry. */ /* Nuke the page table entry. */
...@@ -246,7 +246,7 @@ xip_file_nopage(struct vm_area_struct * area, ...@@ -246,7 +246,7 @@ xip_file_nopage(struct vm_area_struct * area,
__xip_unmap(mapping, pgoff); __xip_unmap(mapping, pgoff);
} else { } else {
/* not shared and writable, use ZERO_PAGE() */ /* not shared and writable, use ZERO_PAGE() */
page = ZERO_PAGE(address); page = ZERO_PAGE(0);
} }
out: out:
......
...@@ -105,7 +105,6 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, ...@@ -105,7 +105,6 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
if (pte_none(*old_pte)) if (pte_none(*old_pte))
continue; continue;
pte = ptep_clear_flush(vma, old_addr, old_pte); pte = ptep_clear_flush(vma, old_addr, old_pte);
/* ZERO_PAGE can be dependant on virtual addr */
pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr); pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
set_pte_at(mm, new_addr, new_pte, pte); set_pte_at(mm, new_addr, new_pte, pte);
} }
......
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