linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page
@ 2020-07-09  2:48 robbieko
  2020-07-10 15:31 ` Vlastimil Babka
  0 siblings, 1 reply; 10+ messages in thread
From: robbieko @ 2020-07-09  2:48 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel, Robbie Ko

From: Robbie Ko <robbieko@synology.com>

When a migrate page occurs, we first create a migration entry
to replace the original pte, and then go to fallback_migrate_page
to execute a writeout if the migratepage is not supported.

In the writeout, we will clear the dirty bit of the page and use
page_mkclean to clear the dirty bit along with the corresponding pte,
but page_mkclean does not support migration entry.

The page ditry bit is cleared, but the dirty bit of the pte still exists,
so if mmap continues to write, it will result in data loss.

We fix the by first remove the migration entry and then clearing
the dirty bits of the page, which also clears the pte's dirty bits.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 mm/migrate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index f37729673558..5c407434b9ba 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -875,10 +875,6 @@ static int writeout(struct address_space *mapping, struct page *page)
 		/* No write method for the address space */
 		return -EINVAL;
 
-	if (!clear_page_dirty_for_io(page))
-		/* Someone else already triggered a write */
-		return -EAGAIN;
-
 	/*
 	 * A dirty page may imply that the underlying filesystem has
 	 * the page on some queue. So the page must be clean for
@@ -889,6 +885,10 @@ static int writeout(struct address_space *mapping, struct page *page)
 	 */
 	remove_migration_ptes(page, page, false);
 
+	if (!clear_page_dirty_for_io(page))
+		/* Someone else already triggered a write */
+		return -EAGAIN;
+
 	rc = mapping->a_ops->writepage(page, &wbc);
 
 	if (rc != AOP_WRITEPAGE_ACTIVATE)
-- 
2.17.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-17 17:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09  2:48 [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page robbieko
2020-07-10 15:31 ` Vlastimil Babka
2020-07-13  1:57   ` Robbie Ko
2020-07-14  9:46     ` Vlastimil Babka
2020-07-14 10:19       ` Kirill A. Shutemov
2020-07-15  2:45         ` Robbie Ko
2020-07-15  8:11           ` Kirill A. Shutemov
2020-07-16 10:15             ` Robbie Ko
2020-07-17 17:41               ` Chris Mason
2020-07-15  2:05       ` Robbie Ko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox