* [REGRESSION] 6.12.y: HugeTLB vmemmap restore corrupts LRU links after THP split
@ 2026-11-27 20:05 Harshit Mogalapalli
2026-11-29 18:59 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Harshit Mogalapalli @ 2026-11-27 20:05 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman, Sasha Levin; +Cc: regressions
Hi Greg/Sasha,
We have hit a regression in our testing(with downstream kernel), and the
same problem is in 6.12.114+, the culprit is 4b7920465ee8
("mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback").
Problem seen while running bunch of ltp tests with HVO enabled (hugepage
vmemmap optimization). The backport copies HugeTLB head metadata into
restored tail descriptors, leaving stale HugeTLB types when the memory
returns to the allocator. After that memory is reused as a THP and
split, incorrect HugeTLB accounting updates overwrite a neighboring
page’s LRU pointer.
[ 4184.918774] RIP: 0010:__list_del_entry_valid_or_report+0x37/0x5a
[ 4184.923355] Code: d2 74 4a 48 85 c9 0f 84 9f 00 00 00 48 b8 00 01 00
00 00 00 ad de 48 39 c2 74 7f 48 b8 22 01 00 00 00 00 ad de 48 39 c1 74
5c <48> 8b 31 48 39 fe 75 40 48 8b 42 08 48 39 c6 75 23 b8 01 00 00 00
[ 4184.940329] RSP: 0018:ffffd022c44e3888 EFLAGS: 00010002
[ 4184.945473] RAX: dead000000000122 RBX: fffff44387a1d040 RCX:
fffff44487a1d089
[ 4184.949857] RDX: fffff44387a1d008 RSI: 0000000000000000 RDI:
fffff44387a1d048
[ 4184.956880] RBP: 0000000000000001 R08: 0000000000000000 R09:
0000000000000000
[ 4184.963933] R10: 0000000000000000 R11: 0000000000000000 R12:
ffff8ddd7ffd4000
[ 4184.968986] R13: 00000000ffffffff R14: 0000000000000001 R15:
0000000000000001
[ 4184.973441] FS: 00007f6ec561b6c0(0000) GS:ffff8ddd6fc00000(0000)
knlGS:0000000000000000
[ 4184.978371] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 4184.983373] CR2: fffff44487a1d089 CR3: 0000000103344000 CR4:
00000000003506f0
[ 4184.987987] Call Trace:
[ 4184.990139] <TASK>
[ 4184.991921] lru_gen_del_folio.constprop.0+0x134/0x1d0
[ 4184.995324] __page_cache_release.part.0+0xa1/0x230
[ 4184.999332] __folio_put+0xd0/0x140
[ 4185.002169] __split_huge_page+0x514/0x720
[ 4185.005202] split_huge_page_to_list_to_order+0x804/0x9e8
[ 4185.008615] deferred_split_scan+0x297/0x4e0
[ 4185.011772] do_shrink_slab+0x13b/0x360
[ 4185.014685] shrink_slab_memcg+0x19e/0x290
[ 4185.017564] drop_slab+0x77/0x100
[ 4185.019906] drop_caches_sysctl_handler+0x94/0xa4
[ 4185.023090] proc_sys_call_handler+0x175/0x350
[ 4185.026031] vfs_write+0x29d/0x450
[ 4185.027975] ksys_write+0x6d/0xf0
[ 4185.031778] do_syscall_64+0x90/0x1c0
[
mm/hugetlb_vmemmap.c:__hugetlb_vmemmap_optimize_folio()
6.12.y (4b7920465ee8) shares the head backing page with the tails:
copy_page(page_to_virt(vmemmap_head), folio);
list_add(&vmemmap_head->lru, vmemmap_pages);
memmap_pages_add(1);
vmemmap_tail = vmemmap_head;
Upstream c7bde43f6daf uses a separate tail-only backing page:
vmemmap_tail = vmemmap_get_tail(h->order, folio_zone(folio));
if (!vmemmap_tail)
return -ENOMEM;
Both states use this in vmemmap_restore_pte():
copy_page(page_to_virt(dst), page_to_virt(src));
The upstream change relies on the separate tail-page representation
introduced by 622026e87c40 ("mm/hugetlb: remove fake head pages"). And
it can;'t be easily cherry-picked
I propose reverting 4b7920465ee8 pending a restoration change adapted
to the 6.12.y metadata layout.
Thanks,
Harshit
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [REGRESSION] 6.12.y: HugeTLB vmemmap restore corrupts LRU links after THP split 2026-11-27 20:05 [REGRESSION] 6.12.y: HugeTLB vmemmap restore corrupts LRU links after THP split Harshit Mogalapalli @ 2026-11-29 18:59 ` Sasha Levin 2026-11-30 3:51 ` [PATCH 6.12.y 6.18.y] mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback Muchun Song 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2026-11-29 18:59 UTC (permalink / raw) To: stable, Greg Kroah-Hartman Cc: Sasha Levin, regressions, Harshit Mogalapalli, Muchun Song > I propose reverting 4b7920465ee8 pending a restoration change adapted > to the 6.12.y metadata layout. I've reverted it on 6.12, and on 6.18 as well, which has the same layout: 622026e87c40 ("mm/hugetlb: remove fake head pages") isn't there either. Muchun, could you send a version of c7bde43f6daf ("mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback") adapted to 6.12.y and 6.18.y? -- Thanks, Sasha ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 6.12.y 6.18.y] mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback 2026-11-29 18:59 ` Sasha Levin @ 2026-11-30 3:51 ` Muchun Song 0 siblings, 0 replies; 3+ messages in thread From: Muchun Song @ 2026-11-30 3:51 UTC (permalink / raw) To: stable, Greg Kroah-Hartman Cc: Sasha Levin, regressions, Harshit Mogalapalli, Muchun Song, Kiryl Shutsemau, Muchun Song, Oscar Salvador (SUSE), David Hildenbrand, Andrew Morton [ Upstream commit c7bde43f6daf70e05a64fbca7efdf6fa93e057dc ] vmemmap_restore_pte() rebuilds restored vmemmap pages from a tail-page template derived from compound_head(). This is wrong when the current PTE already maps a page whose contents are not tail-page metadata. In the rollback path of vmemmap_remap_free(), the first restored PTE is backed by vmemmap_head and contains head-page metadata. Reconstructing that page from a tail-page template overwrites the head-page state and corrupts the restored vmemmap page. Fix this by copying the full page from the page currently mapped by the PTE. Also pass vmemmap_tail to the rollback walk so only PTEs backed by the shared tail page are restored, while the head PTE remains mapped to vmemmap_head. Add VM_WARN_ON_ONCE() checks for unexpected cases. [ backport to 6.12.y and 6.18.y: Neither tree has vmemmap_get_tail() from commit 622026e87c40 ("mm/hugetlb: remove fake head pages"), so vmemmap_tail and vmemmap_head are the same page in both. Copying the page currently mapped by each PTE would plant a fake head page at the start of every restored tail page, and comparing against vmemmap_tail would never skip the head PTE. Instead pass vmemmap_head to the rollback walk so vmemmap_restore_pte() skips its first PTE, and keep the existing tail-page template for the rest. The VM_WARN_ON_ONCE() checks are dropped because boot-time gigantic pages run HVO before their tail struct pages past the first vmemmap page are initialized, so PageTail() is not set on them yet. ] Link: https://lore.kernel.org/20260525025213.2229628-1-songmuchun@bytedance.com Fixes: c0b495b91a47 ("mm/hugetlb: refactor code around vmemmap_walk") Signed-off-by: Muchun Song <songmuchun@bytedance.com> Acked-by: Kiryl Shutsemau <kas@kernel.org> Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Muchun Song <songmuchun@bytedance.com> --- Applies on top of the reverts of 4b7920465ee8 in 6.12.y and d73f79d1a2c2 in 6.18.y. mm/hugetlb_vmemmap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 1394c13c1516..cc813ace1cf2 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -235,6 +235,14 @@ static void vmemmap_restore_pte(pte_t *pte, unsigned long addr, struct page *page; struct page *from, *to; + /* + * On rollback, the first PTE maps the head page to @vmemmap_head, a + * copy of the original head page. Keep that mapping and restore only + * the tail PTEs. + */ + if (walk->vmemmap_head && !walk->nr_walked) + return; + page = list_first_entry(walk->vmemmap_pages, struct page, lru); list_del(&page->lru); @@ -324,6 +332,7 @@ static int vmemmap_remap_free(unsigned long start, unsigned long end, */ walk = (struct vmemmap_remap_walk) { .remap_pte = vmemmap_restore_pte, + .vmemmap_head = vmemmap_head, .vmemmap_pages = vmemmap_pages, .flags = 0, }; base-commit: 1c4b910d87fa5fa5ec787909eda8601d72b367e5 -- 2.54.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 3:51 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 20:05 [REGRESSION] 6.12.y: HugeTLB vmemmap restore corrupts LRU links after THP split Harshit Mogalapalli 2026-11-29 18:59 ` Sasha Levin 2026-11-30 3:51 ` [PATCH 6.12.y 6.18.y] mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback Muchun Song
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.