Commit b4955ce3dd0818b56da532a16c9a4a3804a558ee

Authored by Abhijit Karmarkar
Committed by Linus Torvalds
1 parent c475a8ab62

[PATCH] msync: check pte dirty earlier

It's common practice to msync a large address range regularly, in which
often only a few ptes have actually been dirtied since the previous pass.

sync_pte_range then goes much faster if it tests whether pte is dirty
before locating and accessing each struct page cacheline; and it is hardly
slowed by ptep_clear_flush_dirty repeating that test in the opposite case,
when every pte actually is dirty.

But beware, s390's pte_dirty always says false, since its dirty bit is kept
in the storage key, located via the struct page address.  So skip this
optimization in its case: use a pte_maybe_dirty macro which just says true
if page_test_and_clear_dirty is implemented.

Signed-off-by: Abhijit Karmarkar <abhijitk@veritas.com>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 2 changed files with 5 additions and 0 deletions Side-by-side Diff

include/asm-generic/pgtable.h
... ... @@ -125,6 +125,9 @@
125 125  
126 126 #ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
127 127 #define page_test_and_clear_dirty(page) (0)
  128 +#define pte_maybe_dirty(pte) pte_dirty(pte)
  129 +#else
  130 +#define pte_maybe_dirty(pte) (1)
128 131 #endif
129 132  
130 133 #ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
... ... @@ -34,6 +34,8 @@
34 34  
35 35 if (!pte_present(*pte))
36 36 continue;
  37 + if (!pte_maybe_dirty(*pte))
  38 + continue;
37 39 pfn = pte_pfn(*pte);
38 40 if (!pfn_valid(pfn))
39 41 continue;