The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] mm/migrate_device: fix cache flush when replacing huge zero PMD
@ 2026-08-17  6:08 Hui Su
  2026-08-17  7:35 ` Balbir Singh
  2026-08-17 16:39 ` Zi Yan
  0 siblings, 2 replies; 9+ messages in thread
From: Hui Su @ 2026-08-17  6:08 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Zi Yan, Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple, Balbir Singh,
	linux-mm, linux-kernel, Hui Su

migrate_vma_insert_huge_pmd_page() calls flush_cache_page() before
replacing an existing huge zero PMD. However, the third argument to
flush_cache_page() is a PFN, while addr + HPAGE_PMD_SIZE is an end
virtual address.

More importantly, the mapping being invalidated is PMD-sized rather
than PAGE_SIZE-sized. Flush the whole PMD range with
flush_cache_range(), matching other huge PMD invalidation paths.

Fixes: a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
Signed-off-by: Hui Su <sh_def@163.com>
---
 mm/migrate_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 908d2d4ec43a..098c04c1b124 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -872,7 +872,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate,
 
 	if (flush) {
 		pte_free(vma->vm_mm, pgtable);
-		flush_cache_page(vma, addr, addr + HPAGE_PMD_SIZE);
+		flush_cache_range(vma, addr, addr + HPAGE_PMD_SIZE);
 		pmdp_invalidate(vma, addr, pmdp);
 	} else {
 		pgtable_trans_huge_deposit(vma->vm_mm, pmdp, pgtable);
-- 
2.54.0


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

end of thread, other threads:[~2026-08-17 22:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17  6:08 [PATCH] mm/migrate_device: fix cache flush when replacing huge zero PMD Hui Su
2026-08-17  7:35 ` Balbir Singh
2026-08-17 16:06   ` Andrew Morton
2026-08-17 16:36     ` Hui Su
2026-08-17 21:34       ` Andrew Morton
2026-08-17 22:06         ` Balbir Singh
2026-08-17 22:12         ` Andrew Morton
2026-08-17 16:39 ` Zi Yan
2026-08-17 17:47   ` David Hildenbrand (Arm)

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