Re: [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported
From: David Hildenbrand
Date: Mon Oct 20 2025 - 14:15:16 EST
On 20.10.25 18:14, Gregory Price wrote:
On Mon, Oct 13, 2025 at 10:10:05AM +0200, David Hildenbrand wrote:
On 08.10.25 23:26, Gregory Price wrote:
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 526d27e88b3b..b030850975ef 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -876,12 +876,9 @@ static inline void folio_clear_hugetlb_hwpoison(struct folio *folio)
#ifndef arch_hugetlb_migration_supported
static inline bool arch_hugetlb_migration_supported(struct hstate *h)
{
- if ((huge_page_shift(h) == PMD_SHIFT) ||
+ return ((huge_page_shift(h) == PMD_SHIFT) ||
(huge_page_shift(h) == PUD_SHIFT) ||
- (huge_page_shift(h) == PGDIR_SHIFT))
- return true;
- else
- return false;
+ (huge_page_shift(h) == PGDIR_SHIFT));
switch (huge_page_shift(h)) {
case PMD_SHIFT:
case PUD_SHIFT:
case PGDIR_SHIFT:
PGDIR_SHIFT is not a constant on x86.
Ah, probably because of 4 vs. 5 level page tables. On x86 the check doesn't even make any sense as we don't support PGD-sized pages.
If we could rule that out at compile time, it would be nice. But I don't think we have a way to test that support at compile time.
But anyhow, nothing against what we have in this patch here
Acked-by: David Hildenbrand <david@xxxxxxxxxx>
--
Cheers
David / dhildenb