mm/hugetlb: warn instead of silently bailing gigantic pages without runtime support

remove_hugetlb_folio() and __update_and_free_hugetlb_folio() silently
return for gigantic hstates that lack runtime freeing support.  All
callers should already filter such hstates upstream, so turn the silent
bail into a VM_WARN_ON_ONCE to catch caller regressions instead of masking
them.

Link: https://lore.kernel.org/20260823044118.1097121-3-xialonglong2025@163.com
Signed-off-by: Longlong Xia <xialonglong@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Assisted-by: Codex:gpt-5.6-sol
Cc: David Hildenbrand <david@kernel.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
This commit is contained in:
Longlong Xia 2026-08-23 12:40:52 +08:00 committed by Andrew Morton
parent c0f106b518
commit a9ce28ef2a

View File

@ -1396,8 +1396,11 @@ void remove_hugetlb_folio(struct hstate *h, struct folio *folio,
VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio_rsvd(folio), folio);
lockdep_assert_held(&hugetlb_lock);
if (hstate_is_gigantic_no_runtime(h))
if (hstate_is_gigantic_no_runtime(h)) {
/* Callers must filter gigantic_no_runtime upstream. */
VM_WARN_ON_ONCE(1);
return;
}
list_del(&folio->lru);
@ -1458,8 +1461,11 @@ static void __update_and_free_hugetlb_folio(struct hstate *h,
{
bool clear_flag = folio_test_hugetlb_vmemmap_optimized(folio);
if (hstate_is_gigantic_no_runtime(h))
if (hstate_is_gigantic_no_runtime(h)) {
/* Callers must filter gigantic_no_runtime upstream. */
VM_WARN_ON_ONCE(1);
return;
}
/*
* If we don't know which subpages are hwpoisoned, we can't free