[Devel] [PATCH rh7] mm/hmm: Restore removed hunk in copy_one_pte()

Andrey Ryabinin aryabinin at virtuozzo.com
Mon Aug 28 14:54:38 MSK 2017


Rebased "ms/mm: remove rest usage of VM_NONLINEAR and pte_file()"
removed huge hunk from copy_one_pte for no reason. Bring it back

https://jira.sw.ru/browse/PSBM-70740

Fixes: be8e22c9c444 ("ms/mm: remove rest usage of VM_NONLINEAR and pte_file()")
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/memory.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index e53e8dd288eb..c30a042cebf5 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -879,13 +879,32 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 					pte = pte_swp_mksoft_dirty(pte);
 				set_pte_at(src_mm, addr, src_pte, pte);
 			}
-		} else {
+		} else if (is_hmm_entry(entry)) {
+			page = hmm_entry_to_page(entry);
+
+			/*
+			 * Update rss count even for un-addressable
+			 * page as they should be consider just like
+			 * any other page.
+			 */
+			get_page(page);
+			rss[mm_counter(page)]++;
+			page_dup_rmap(page);
+
+			if (is_write_hmm_entry(entry) &&
+				is_cow_mapping(vm_flags)) {
+				make_hmm_entry_read(&entry);
+				pte = swp_entry_to_pte(entry);
+				if (pte_swp_soft_dirty(*src_pte))
+					pte = pte_swp_mksoft_dirty(pte);
+				set_pte_at(src_mm, addr, src_pte, pte);
+			}
+		} else
 			/*
 			 * This can not happen because HMM migration holds
 			 * mmap_sem in read mode.
 			 */
-			VM_BUG_ON(is_hmm_entry(entry));
-		}
+			 VM_BUG_ON(is_hmm_entry(entry));
 		goto out_set_pte;
 	}
 
-- 
2.13.5



More information about the Devel mailing list