From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 40B6752758E; Wed, 30 Sep 2026 17:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790575; cv=none; b=kjdt7ccqABDv45OIsw1NZM63fIUicJEojoscVc5O9n9vhgmaT1xw5umn1PR85f1dBv1ciH+w+n39dly7HKa5qk/Yjb+gSxQ4WqdD0b/PCjOiRx7qo+6TeFeZWYy8b1MVAZNBSgd1rOklnqXzh8u5VMFfGTncKPpm+vsfStY5vCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790575; c=relaxed/simple; bh=bxycOoI0G158LR21TBATt3n1sf7I4EYi4oYNvAo6z/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T32kDTArRdf3JJqteixFOopDDOJheij2xzXZ+MCv8vW1QKInbEl1H0IIR5usOuhzS+sz+ZdSAxh2MLrZ7AnALmfidb/PZLbMCRnasD7GDlfmgMkirmxfCXvbaneFUeroYHMP3p5FQLix14FVSw7qjNBRz5qAzPzWzkR5eVzNYz4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S57cWm5M; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="S57cWm5M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 785F51F000FF; Wed, 30 Sep 2026 17:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790790574; bh=bmcJzbGZhr/QWBVQdeF00fJHMW5TYgXuhynWqD0KzQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S57cWm5MO2p8jRssoBlIU9yOkxso5nD9mKltK+UOQ8kP89XNjF1y5yyA04GMDVS1J kxKyVr4TI/wy1bTMv2P+WV7hvNArOimLiD3and1gKEpWIZ906yWvM4ef5W7z7egcwV x0e47BMDwl5AzotvQpa9Wx3LE2F2XToFplPywAPE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Usama Arif , Andrew Morton , Shakeel Butt , Kefeng Wang , David Hildenbrand , Oscar Salvador , Johannes Weiner , Muchun Song , Rik van Riel , SeongJae Park , Sasha Levin Subject: [PATCH 6.12 832/877] mm/hugetlb: create hstate_is_gigantic_no_runtime helper Date: Wed, 30 Sep 2026 17:29:03 +0200 Message-ID: <20260930152432.688433935@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152414.738996857@linuxfoundation.org> References: <20260930152414.738996857@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Usama Arif [ Upstream commit a743e0af503a633e4ca68a100d9b2a1a071fe8ae ] This is a common condition used to skip operations that cannot be performed on gigantic pages when runtime support is disabled. This helper is introduced as the condition will exist even more when allowing "overcommit" of gigantic hugepages. No functional change intended with this patch. Link: https://lkml.kernel.org/r/20251009172433.4158118-1-usamaarif642@gmail.com Signed-off-by: Usama Arif Suggested-by: Andrew Morton Reviewed-by: Shakeel Butt Reviewed-by: Kefeng Wang Acked-by: David Hildenbrand Acked-by: Oscar Salvador Cc: Johannes Weiner Cc: Muchun Song Cc: Rik van Riel Cc: SeongJae Park Signed-off-by: Andrew Morton Stable-dep-of: a363c62a653c ("mm/hugetlb: do not dissolve gigantic pages without runtime support") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -104,6 +104,17 @@ static void hugetlb_free_folio(struct fo folio_put(folio); } +/* + * Check if the hstate represents gigantic pages but gigantic page + * runtime support is not available. This is a common condition used to + * skip operations that cannot be performed on gigantic pages when runtime + * support is disabled. + */ +static inline bool hstate_is_gigantic_no_runtime(struct hstate *h) +{ + return hstate_is_gigantic(h) && !gigantic_page_runtime_supported(); +} + static inline bool subpool_is_free(struct hugepage_subpool *spool) { if (spool->count) @@ -1594,7 +1605,7 @@ static void remove_hugetlb_folio(struct VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio_rsvd(folio), folio); lockdep_assert_held(&hugetlb_lock); - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) + if (hstate_is_gigantic_no_runtime(h)) return; list_del(&folio->lru); @@ -1656,7 +1667,7 @@ static void __update_and_free_hugetlb_fo { bool clear_flag = folio_test_hugetlb_vmemmap_optimized(folio); - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) + if (hstate_is_gigantic_no_runtime(h)) return; /* @@ -2564,7 +2575,7 @@ static void return_unused_surplus_pages( /* Uncommit the reservation */ h->resv_huge_pages -= unused_resv_pages; - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) + if (hstate_is_gigantic_no_runtime(h)) goto out; /* @@ -3493,7 +3504,7 @@ static void __init hugetlb_init_hstates( * - If CMA allocation is possible, we can not demote * HUGETLB_PAGE_ORDER or smaller size pages. */ - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) + if (hstate_is_gigantic_no_runtime(h)) continue; if (hugetlb_cma_size && h->order <= HUGETLB_PAGE_ORDER) continue; @@ -3938,7 +3949,7 @@ static ssize_t __nr_hugepages_store_comm int err; nodemask_t nodes_allowed, *n_mask; - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) + if (hstate_is_gigantic_no_runtime(h)) return -EINVAL; if (nid == NUMA_NO_NODE) {