Commit 861f2fb8 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] mm: zap_pte out of line

There used to be just one call to zap_pte, but it shouldn't be inline now
there are two.  Check for the common case pte_none before calling, and move
its rss accounting up into install_page or install_file_pte - which helps the
next patch.
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 d0de32d9
...@@ -20,34 +20,32 @@ ...@@ -20,34 +20,32 @@
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
static inline void zap_pte(struct mm_struct *mm, struct vm_area_struct *vma, static int zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long addr, pte_t *ptep) unsigned long addr, pte_t *ptep)
{ {
pte_t pte = *ptep; pte_t pte = *ptep;
struct page *page = NULL;
if (pte_none(pte))
return;
if (pte_present(pte)) { if (pte_present(pte)) {
unsigned long pfn = pte_pfn(pte); unsigned long pfn = pte_pfn(pte);
struct page *page;
flush_cache_page(vma, addr, pfn); flush_cache_page(vma, addr, pfn);
pte = ptep_clear_flush(vma, addr, ptep); pte = ptep_clear_flush(vma, addr, ptep);
if (unlikely(!pfn_valid(pfn))) { if (unlikely(!pfn_valid(pfn))) {
print_bad_pte(vma, pte, addr); print_bad_pte(vma, pte, addr);
return; goto out;
} }
page = pfn_to_page(pfn); page = pfn_to_page(pfn);
if (pte_dirty(pte)) if (pte_dirty(pte))
set_page_dirty(page); set_page_dirty(page);
page_remove_rmap(page); page_remove_rmap(page);
page_cache_release(page); page_cache_release(page);
dec_mm_counter(mm, file_rss);
} else { } else {
if (!pte_file(pte)) if (!pte_file(pte))
free_swap_and_cache(pte_to_swp_entry(pte)); free_swap_and_cache(pte_to_swp_entry(pte));
pte_clear(mm, addr, ptep); pte_clear(mm, addr, ptep);
} }
out:
return !!page;
} }
/* /*
...@@ -96,9 +94,9 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -96,9 +94,9 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
if (page_mapcount(page) > INT_MAX/2) if (page_mapcount(page) > INT_MAX/2)
goto err_unlock; goto err_unlock;
zap_pte(mm, vma, addr, pte); if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
inc_mm_counter(mm, file_rss);
inc_mm_counter(mm, file_rss);
flush_icache_page(vma, page); flush_icache_page(vma, page);
set_pte_at(mm, addr, pte, mk_pte(page, prot)); set_pte_at(mm, addr, pte, mk_pte(page, prot));
page_add_file_rmap(page); page_add_file_rmap(page);
...@@ -145,7 +143,8 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -145,7 +143,8 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
if (!pte) if (!pte)
goto err_unlock; goto err_unlock;
zap_pte(mm, vma, addr, pte); if (!pte_none(*pte) && zap_pte(mm, vma, addr, pte))
dec_mm_counter(mm, file_rss);
set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff)); set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
pte_val = *pte; pte_val = *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