mm/migrate: set swap entry values of THP tail pages properly.
Subsystems (2)
PATCH 1/1 mm/migrate: set swap entry values of THP tail pages properly.
From: Zi Yan <[email protected]>
The tail pages in a THP can have swap entry information stored in their private field. When migrating to a new page, all tail pages of the new page need to update ->private to avoid future data corruption.
Corresponding swapcache entries need to be updated as well. e71769ae5260 ("mm: enable thp migration for shmem thp") fixed it already.
--- mm/migrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/migrate.c +5 -1
@@ -514,8 +514,12 @@ int migrate_page_move_mapping(struct address_space *mapping,if (PageSwapBacked (page)) {__SetPageSwapBacked (newpage);if (PageSwapCache (page)) { +int i; +SetPageSwapCache (newpage); -set_page_private (newpage,page_private (page)); +for (i =0 ; i < (1 <<compound_order (page)); i++) +set_page_private (newpage + i, +page_private (page + i)); } }else {VM_BUG_ON_PAGE (PageSwapCache (page), page);
Signature · 1 line
2.43.0
Quoted 24 lines · Zi Yan
From: Zi Yan <[email protected]>
The tail pages in a THP can have swap entry information stored in their private field. When migrating to a new page, all tail pages of the new page need to update ->private to avoid future data corruption.
Corresponding swapcache entries need to be updated as well.
e71769ae5260("mm: enable thp migration for shmem thp") fixed it already.Fixes 616b8371539a ("mm: thp: enable thp migration in generic path")Signed-off-by Zi Yan <[email protected]>--- mm/migrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)mm/migrate.c +0
-0@@ -514,8 +514,12 @@ int migrate_page_move_mapping(struct address_space *mapping,if (PageSwapBacked (page)) {__SetPageSwapBacked (newpage);if (PageSwapCache (page)) {
mm/migrate.c int migrate_page_move_mapping(struct address_space *mapping, · line 525
Quoted 10 lines
mm/migrate.c +5
-1+int i; +SetPageSwapCache (newpage); -set_page_private (newpage,page_private (page)); +for (i =0 ; i < (1 <<compound_order (page)); i++) +set_page_private (newpage + i, +page_private (page + i)); } }else {VM_BUG_ON_PAGE (PageSwapCache (page), page);
Thanks for taking care of all of these!
Signature · 3 lines
Cheers, David / dhildenb