From nobody Mon Sep 28 10:49:11 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6488F352C4E for ; Sun, 23 Aug 2026 04:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787460299; cv=none; b=kxPW+cfJCFEkZdaCW9l6bYAq+Cu9xRQva98dPjT7JXabaIhXmRwDX1RnhOgxvSIQqaFFIlQ2jpl2ZvtFj7motaLkbwNQkQwPgcODEC57Uj8zb+0TH9YMMiHMNW3JaV4i8LUhISWLxJdQA/Q9IOmHbJoruycyHG4Uskwg7hxbKV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787460299; c=relaxed/simple; bh=Lu8buoI1HLh2N8JUx4jfe6Xs0GI7tAO6loPlSkeBSOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kBJllVF58dl6t+b3djO2hsIh+L3RRWjx7nLxrRJclTan1Zot1Y/SbqRv8cyR2c27UJeTg8wy/DyAsXEOVB8JDOV0ILa6+WPFZ4m5tY6TlncMmynL1A8lc1r7GC+1yOZtt4KsLl+sx2LjKePD/0WK/qPxgjQWRQnf2nftCg+7LJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=Pcf6htPu; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Pcf6htPu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=rp J8lj+pnCjeQ7J7KuEkjV/sMqGkbWtnr3XBGPFmpoc=; b=Pcf6htPudBQzdQoW2s /XVkCZKemfMRGKJRUbUhwIdGZOB9wrVOrwywLGG4gNn3+wtgVADeWlBuMByW9Kf2 YZMfGItNvkD2thWf3eLGpuOvg9G/nRKy95GarVfl3CNqtorghmoWNwoS5Bi+XY/L vuf4uLCZtYsywGqyGUa7kAg54= Received: from XLL-9950X.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wAXH8z4eYpqyqI1Qw--.15058S3; Sun, 23 Aug 2026 12:41:33 +0800 (CST) From: Longlong Xia To: muchun.song@linux.dev, osalvador@suse.de, akpm@linux-foundation.org, david@kernel.org Cc: mike.kravetz@oracle.com, mhocko@suse.com, linmiaohe@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xialonglong@kylinos.cn Subject: [PATCH v2 1/2] mm/hugetlb: do not dissolve gigantic pages without runtime support Date: Sun, 23 Aug 2026 12:40:51 +0800 Message-ID: <20260823044118.1097121-2-xialonglong2025@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260823044118.1097121-1-xialonglong2025@163.com> References: <20260823044118.1097121-1-xialonglong2025@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wAXH8z4eYpqyqI1Qw--.15058S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw4xCry3Kr1xKrWUuw4UArb_yoW8JFWrpF WkWrs8GrWUXF9rCF4xJr4UXrn8Gr95Xry09a4xKF43ZFnxG34DKrs8Xa18tayFvw1fJa1f urWqqrWDWF4q9aUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j7mi_UUUUU= X-CM-SenderInfo: x0ldz0pqjo00rjsqjki6rwjhhfrp/xtbC9x3a02qKef2ZCAAA3W Content-Type: text/plain; charset="utf-8" From: Longlong Xia 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. Fixes: 6eb4e88a6d27 ("hugetlb: create remove_hugetlb_page() to separate fun= ctionality") Assisted-by: Codex:gpt-5.6-sol Signed-off-by: Longlong Xia Acked-by: Muchun Song --- mm/hugetlb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e93c4d2456aa..8b9cb476a41b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1977,6 +1977,15 @@ int dissolve_free_hugetlb_folio(struct folio *folio) struct hstate *h =3D folio_hstate(folio); bool adjust_surplus =3D false; =20 + /* + * 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; =20 --=20 2.43.0 From nobody Mon Sep 28 10:49:11 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACBC9217723 for ; Sun, 23 Aug 2026 04:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787460161; cv=none; b=f+VNFC1pLnbL79i00DxNHMDjrp4M1wxMzGY9tmqR9mC+PbB/ZFpKYfc0xJfpDL14nXnVjn/EEeJMtKm+3uqZrsMVzk/354GRsMO9MXZ6cLMsbIMiXQEijdqpUSTojKK0/FQ0ofTqwUTRV0QeAhEHYabyRwej9rAsDQU86VocVRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787460161; c=relaxed/simple; bh=MA7QllnRjzYXPr92t3cR40ET4L/VRl2snKYUDZWA2F4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lIGWNcceLcOthdxE5O0y+a1fLTmxJCksHOcEWngWDaQKdUt4EUe8IxNqwLld4gG+U/e3DymjqPJ7s6DJZBR6Plg6WkbflyN5h5hH0n3WH5M+pxT3j20AYHCI9DZ2WQ25bPWZY+oHqol1aWLKbpk/Vx5nUrGl0E3VsGAJgR5Kgrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=WC2C+Uc6; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="WC2C+Uc6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=PS oMKkEw18jI78qsF/na21m8RpLE64CUxHlryaUYZCA=; b=WC2C+Uc6A7qIqNvt2s iuI447NK8mJqPJ0QjVFi9AY/TxjHEeCMr9qwsEKhe8N7TQTbXcd/2zOdzFziY10k HotBFesl1rsw8/KW7EwHOa7vYxo+JAs8znGeNE5m2vjuO0jtciMcS1UVoN+lSbQT 1tMc+dS9kJZ/av2cc7rUrsjb0= Received: from XLL-9950X.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wAXH8z4eYpqyqI1Qw--.15058S4; Sun, 23 Aug 2026 12:41:34 +0800 (CST) From: Longlong Xia To: muchun.song@linux.dev, osalvador@suse.de, akpm@linux-foundation.org, david@kernel.org Cc: mike.kravetz@oracle.com, mhocko@suse.com, linmiaohe@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xialonglong@kylinos.cn Subject: [PATCH v2 2/2] mm/hugetlb: warn instead of silently bailing gigantic pages without runtime support Date: Sun, 23 Aug 2026 12:40:52 +0800 Message-ID: <20260823044118.1097121-3-xialonglong2025@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260823044118.1097121-1-xialonglong2025@163.com> References: <20260823044118.1097121-1-xialonglong2025@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wAXH8z4eYpqyqI1Qw--.15058S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFW3Zw1ftr4DKrWfuF1xKrg_yoW8XF1kpF WkW395Gw48XasrZF1kJF1DXrn8C39aqrWjvrWSkF43AFZxJw1DKFyDGr10qayFkrZ3Ga1r Cr48XFsrXa1F9aDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j2ksDUUUUU= X-CM-SenderInfo: x0ldz0pqjo00rjsqjki6rwjhhfrp/xtbC+B7a02qKef6dwgAA3X Content-Type: text/plain; charset="utf-8" From: Longlong Xia 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. Assisted-by: Codex:gpt-5.6-sol Signed-off-by: Longlong Xia Acked-by: Muchun Song --- mm/hugetlb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 8b9cb476a41b..67a502293698 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1398,8 +1398,11 @@ void remove_hugetlb_folio(struct hstate *h, struct f= olio *folio, VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio_rsvd(folio), folio); =20 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; + } =20 list_del(&folio->lru); =20 @@ -1460,8 +1463,11 @@ static void __update_and_free_hugetlb_folio(struct h= state *h, { bool clear_flag =3D folio_test_hugetlb_vmemmap_optimized(folio); =20 - 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; + } =20 /* * If we don't know which subpages are hwpoisoned, we can't free --=20 2.43.0