[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250810214745.2368-2-thorsten.blum@linux.dev>
Date: Sun, 10 Aug 2025 23:47:45 +0200
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Muchun Song <muchun.song@...ux.dev>,
Oscar Salvador <osalvador@...e.de>,
David Hildenbrand <david@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] mm/hugetlb: Use max() to simplify hugetlb_vmemmap_optimizable_size()
Use max() to simplify hugetlb_vmemmap_optimizable_size() and improve its
readability.
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
---
mm/hugetlb_vmemmap.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 18b490825215..4da44b1e8e1a 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -11,6 +11,7 @@
#include <linux/hugetlb.h>
#include <linux/io.h>
#include <linux/memblock.h>
+#include <linux/minmax.h>
/*
* Reserve one vmemmap page, all vmemmap addresses are mapped to it. See
@@ -44,11 +45,10 @@ static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h)
*/
static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h)
{
- int size = hugetlb_vmemmap_size(h) - HUGETLB_VMEMMAP_RESERVE_SIZE;
-
if (!is_power_of_2(sizeof(struct page)))
return 0;
- return size > 0 ? size : 0;
+
+ return max(0, hugetlb_vmemmap_size(h) - HUGETLB_VMEMMAP_RESERVE_SIZE);
}
#else
static inline int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio)
--
2.50.1
Powered by blists - more mailing lists