From 04cf7ec7ed9f44ddf2b674e8ebbe0087e87708f3 Mon Sep 17 00:00:00 2001 From: Ye Liu Date: Thu, 14 Aug 2025 17:00:52 +0800 Subject: [PATCH] mm/page_alloc: simplify lowmem_reserve max calculation Use max() to find the maximum lowmem_reserve value and min_t() to cap it to managed_pages in calculate_totalreserve_pages(), instead of open-coding the comparisons. No functional change. Link: https://lkml.kernel.org/r/20250814090053.22241-1-ye.liu@linux.dev Signed-off-by: Ye Liu Acked-by: Johannes Weiner Acked-by: Zi Yan Reviewed-by: Wei Yang Cc: Brendan Jackman Cc: Michal Hocko Cc: Suren Baghdasaryan Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 09241bb7663e..35b2bf61b78d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6237,8 +6237,7 @@ static void calculate_totalreserve_pages(void) /* Find valid and maximum lowmem_reserve in the zone */ for (j = i; j < MAX_NR_ZONES; j++) { - if (zone->lowmem_reserve[j] > max) - max = zone->lowmem_reserve[j]; + max = max(max, zone->lowmem_reserve[j]); } /* we treat the high watermark as reserved pages. */ -- 2.51.0