[PATCH v2 1/2] mm/hugetlb: Remove unnecessary if condition
From: Joshua Hahn
Date: Fri Jan 16 2026 - 14:27:19 EST
if (map_chg) is always true, since it is nested in another if statement
which checks for map_chg == MAP_CHG_NEEDED, which is equal to 1.
if (unlikely(map_chg == MAP_CHG_NEEDED && retval == 0)) {
...
if (map_chg) {
...
}
}
Remove the check, un-indent, and collapse the function call for
readability.
No functional change intended.
Acked-by: David Hildenbrand (Red Hat) <david@xxxxxxxxxx>
Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
Signed-off-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>
---
v1 --> v2:
- Collapse the "folio" argument into the line above, as suggested by Andrew
and SeongJae.
- Explicitly note that MAP_CHG_NEEDED == 1, as suggested by David.
- Collect signatures.
mm/hugetlb.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 5a147026633f..2e5592c5cbb2 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3028,13 +3028,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
rsv_adjust = hugepage_subpool_put_pages(spool, 1);
hugetlb_acct_memory(h, -rsv_adjust);
- if (map_chg) {
- spin_lock_irq(&hugetlb_lock);
- hugetlb_cgroup_uncharge_folio_rsvd(
- hstate_index(h), pages_per_huge_page(h),
- folio);
- spin_unlock_irq(&hugetlb_lock);
- }
+ spin_lock_irq(&hugetlb_lock);
+ hugetlb_cgroup_uncharge_folio_rsvd(
+ hstate_index(h), pages_per_huge_page(h), folio);
+ spin_unlock_irq(&hugetlb_lock);
}
}
--
2.47.3