summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLonglong Xia <xialonglong@kylinos.cn>2026-08-23 12:40:51 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-09-17 22:42:40 -0700
commita363c62a653cc8b3e21da9545fa4e028ef50f9c3 (patch)
tree58385b504d4647430aa79521dc718a361e2ccebe
parent7891fbb9512f127826e1d5dbf380ee212bd15eb0 (diff)
downloadlinux-next-a363c62a653cc8b3e21da9545fa4e028ef50f9c3.tar.gz
linux-next-a363c62a653cc8b3e21da9545fa4e028ef50f9c3.zip
mm/hugetlb: do not dissolve gigantic pages without runtime support
dissolve_free_hugetlb_folio() doesn't check hstate_is_gigantic_no_runtime(h) though remove_hugetlb_folio()/ update_and_free_hugetlb_folio() silently bail for such folios, so it frees a still-listed folio and, on vmemmap restore failure, the add_hugetlb_folio() rollback corrupts the free list. Link: https://lore.kernel.org/20260823044118.1097121-2-xialonglong2025@163.com Fixes: 6eb4e88a6d27 ("hugetlb: create remove_hugetlb_page() to separate functionality") Signed-off-by: Longlong Xia <xialonglong@kylinos.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Assisted-by: Codex:gpt-5.6-sol Acked-by: Muchun Song <muchun.song@linux.dev> Cc: David Hildenbrand <david@kernel.org> Cc: Miaohe Lin <linmiaohe@huawei.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: <stable@vger.kernel.org>
-rw-r--r--mm/hugetlb.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 4f6f58bf3db6..d28972cd33f5 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1967,6 +1967,15 @@ retry:
struct hstate *h = folio_hstate(folio);
bool adjust_surplus = false;
+ /*
+ * remove_hugetlb_folio()/update_and_free_hugetlb_folio() bail
+ * for gigantic hstates without runtime support, so dissolving one
+ * here would leave it on the free list and, on vmemmap restore
+ * failure, the add_hugetlb_folio() rollback corrupts that list.
+ */
+ if (hstate_is_gigantic_no_runtime(h))
+ goto out;
+
if (!available_huge_pages(h))
goto out;