[patch 5/5] Optimize page_mkclean_one

Martin Schwidefsky
2007-06-29T14:15:11Z

[-- Attachment #1: 006-page-mkclean.diff --]
[-- Type: text/plain, Size: 1156 bytes --]

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

page_mkclean_one is used to clear the dirty bit and to set the write
protect bit of a pte. In additions it returns true if the pte either
has been dirty or if it has been writable. As far as I can see the
function should return true only if the pte has been dirty, or page
writeback will needlessly write a clean page.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

mm/rmap.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)

diff -urpN linux-2.6/mm/rmap.c linux-2.6-patched/mm/rmap.c
--- linux-2.6/mm/rmap.c 2007-06-29 09:58:33.000000000 +0200
+++ linux-2.6-patched/mm/rmap.c 2007-06-29 15:44:58.000000000 +0200
@@ -433,11 +433,12 @@ static int page_mkclean_one(struct page

flush_cache_page(vma, address, pte_pfn(*pte));
entry = ptep_clear_flush(vma, address, pte);
+ if (pte_dirty(entry))
+ ret = 1;
entry = pte_wrprotect(entry);
entry = pte_mkclean(entry);
set_pte_at(mm, address, pte, entry);
lazy_mmu_prot_update(entry);
- ret = 1;
}

pte_unmap_unlock(pte, ptl);