@@ -961,17 +961,25 @@ static int page_vma_mkclean_one(struct page_vma_mapped_walk *pvmw)
address = pvmw->address;
if (pvmw->pte) {
- pte_t entry;
+ pte_t entry, oldpte;
pte_t *pte = pvmw->pte;
if (!pte_dirty(*pte) && !pte_write(*pte))
continue;
flush_cache_page(vma, address, pte_pfn(*pte));
- entry = ptep_clear_flush(vma, address, pte);
- entry = pte_wrprotect(entry);
+ oldpte = ptep_modify_prot_start(pvmw->vma, address,
+ pte);
+
+ entry = pte_wrprotect(oldpte);
entry = pte_mkclean(entry);
- set_pte_at(vma->vm_mm, address, pte, entry);
+
+ if (pte_needs_flush(oldpte, entry) ||
+ mm_tlb_flush_pending(vma->vm_mm))
+ flush_tlb_page(vma, address);
+
+ ptep_modify_prot_commit(vma, address, pte, oldpte,
+ entry);
ret = 1;
} else {
#ifdef CONFIG_TRANSPARENT_HUGEPAGE