diff mbox series

mm/hugetlb: Make __NR_USED_SUBPAGE check conditional

Message ID 20241202090728.78935-1-anshuman.khandual@arm.com (mailing list archive)
State New
Headers show
Series mm/hugetlb: Make __NR_USED_SUBPAGE check conditional | expand

Commit Message

Anshuman Khandual Dec. 2, 2024, 9:07 a.m. UTC
The HugeTLB order check against __NR_USED_SUBPAGE is required only when
HUGETLB_PAGE_OPTIMIZE_VMEMMAP is enabled. Hence BUG_ON() trigger should
happen only when applicable.

Cc: Muchun Song <muchun.song@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This patch applies on v6.13-rc1

 mm/hugetlb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Oscar Salvador Dec. 2, 2024, 10:37 a.m. UTC | #1
On Mon, Dec 02, 2024 at 02:37:28PM +0530, Anshuman Khandual wrote:
> The HugeTLB order check against __NR_USED_SUBPAGE is required only when
> HUGETLB_PAGE_OPTIMIZE_VMEMMAP is enabled. Hence BUG_ON() trigger should
> happen only when applicable.
> 
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
...
> +
>  	BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE);
> +#ifdef HUGETLB_PAGE_OPTIMIZE_VMEMMAP

 #ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP ?
diff mbox series

Patch

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ea2ed8e301ef..b7443c7f3e0c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4513,11 +4513,13 @@  void __init hugetlb_add_hstate(unsigned int order)
 	struct hstate *h;
 	unsigned long i;
 
-	if (size_to_hstate(PAGE_SIZE << order)) {
+	if (size_to_hstate(PAGE_SIZE << order))
 		return;
-	}
+
 	BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE);
+#ifdef HUGETLB_PAGE_OPTIMIZE_VMEMMAP
 	BUG_ON(order < order_base_2(__NR_USED_SUBPAGE));
+#endif
 	h = &hstates[hugetlb_max_hstate++];
 	__mutex_init(&h->resize_lock, "resize mutex", &h->resize_key);
 	h->order = order;