page->private should not be set in tail pages. Commit 4265d67e405a
("mm/migrate_device: add THP splitting during migration") removed it
without a proper reason. Add it back.

Signed-off-by: Zi Yan <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: "Liam R. Howlett" <[email protected]>
Cc: Nico Pache <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: Dev Jain <[email protected]>
Cc: Barry Song <[email protected]>
Cc: Lance Yang <[email protected]>
Cc: [email protected]
---
 mm/huge_memory.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 27316d741927..6b57d219fc97 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3548,6 +3548,16 @@ static void __split_folio_to_order(struct folio *folio, 
int old_order,
                new_folio->mapping = folio->mapping;
                new_folio->index = folio->index + i;
 
+               /*
+                * page->private should not be set in tail pages. Fix up and 
warn once
+                * if private is unexpectedly set. Do it before swap.val 
assignment
+                * since private overlaps with swap.val.
+                */
+               if (unlikely(new_folio->private)) {
+                       VM_WARN_ON_ONCE_PAGE(true, new_head);
+                       new_folio->private = NULL;
+               }
+
                if (folio_test_swapcache(folio))
                        new_folio->swap.val = folio->swap.val + i;
 
-- 
2.51.0

Reply via email to