Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/hugetlb: create hstate_is_gigantic_no_runtime helper

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 <usamaarif642@gmail.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Rik van Riel <riel@surriel.com>
Cc: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Usama Arif and committed by
Andrew Morton
a743e0af 2783088e

+16 -5
+16 -5
mm/hugetlb.c
··· 135 135 folio_put(folio); 136 136 } 137 137 138 + /* 139 + * Check if the hstate represents gigantic pages but gigantic page 140 + * runtime support is not available. This is a common condition used to 141 + * skip operations that cannot be performed on gigantic pages when runtime 142 + * support is disabled. 143 + */ 144 + static inline bool hstate_is_gigantic_no_runtime(struct hstate *h) 145 + { 146 + return hstate_is_gigantic(h) && !gigantic_page_runtime_supported(); 147 + } 148 + 138 149 static inline bool subpool_is_free(struct hugepage_subpool *spool) 139 150 { 140 151 if (spool->count) ··· 1546 1535 VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio_rsvd(folio), folio); 1547 1536 1548 1537 lockdep_assert_held(&hugetlb_lock); 1549 - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) 1538 + if (hstate_is_gigantic_no_runtime(h)) 1550 1539 return; 1551 1540 1552 1541 list_del(&folio->lru); ··· 1608 1597 { 1609 1598 bool clear_flag = folio_test_hugetlb_vmemmap_optimized(folio); 1610 1599 1611 - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) 1600 + if (hstate_is_gigantic_no_runtime(h)) 1612 1601 return; 1613 1602 1614 1603 /* ··· 2502 2491 /* Uncommit the reservation */ 2503 2492 h->resv_huge_pages -= unused_resv_pages; 2504 2493 2505 - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) 2494 + if (hstate_is_gigantic_no_runtime(h)) 2506 2495 goto out; 2507 2496 2508 2497 /* ··· 3716 3705 * - If CMA allocation is possible, we can not demote 3717 3706 * HUGETLB_PAGE_ORDER or smaller size pages. 3718 3707 */ 3719 - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) 3708 + if (hstate_is_gigantic_no_runtime(h)) 3720 3709 continue; 3721 3710 if (hugetlb_cma_total_size() && h->order <= HUGETLB_PAGE_ORDER) 3722 3711 continue; ··· 4193 4182 int err; 4194 4183 nodemask_t nodes_allowed, *n_mask; 4195 4184 4196 - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) 4185 + if (hstate_is_gigantic_no_runtime(h)) 4197 4186 return -EINVAL; 4198 4187 4199 4188 if (nid == NUMA_NO_NODE) {