diff --git a/mm/migrate.c b/mm/migrate.c index 003886606a2251cab9b1e1e50d128d5d5f1de497..337a40201c827bd85e6a7cb9182a8589c96e2932 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1986,6 +1986,13 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, (vma->vm_flags & VM_EXEC)) goto out; + /* + * Also do not migrate dirty pages as not all filesystems can move + * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. + */ + if (page_is_file_cache(page) && PageDirty(page)) + goto out; + /* * Rate-limit the amount of data that is being migrated to a node. * Optimal placement is no good if the memory bus is saturated and diff --git a/mm/mprotect.c b/mm/mprotect.c index c1d6af7455da542b9462cfc5ef8d64fa1d386a4f..625608bc89621a4033751717ebc3e8f0b3ab1f30 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,14 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, page_mapcount(page) != 1) continue; + /* + * While migration can move some dirty pages, + * it cannot move them all from MIGRATE_ASYNC + * context. + */ + if (page_is_file_cache(page) && PageDirty(page)) + continue; + /* Avoid TLB flush if possible */ if (pte_protnone(oldpte)) continue;