]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/page_alloc: simplify lowmem_reserve max calculation
authorYe Liu <liuye@kylinos.cn>
Thu, 14 Aug 2025 09:00:52 +0000 (17:00 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 18 Aug 2025 05:08:42 +0000 (22:08 -0700)
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 <liuye@kylinos.cn>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index 09241bb7663e039a8758abaae8cee0a95830cf70..35b2bf61b78d582178d2cd955c736db735c0daef 100644 (file)
@@ -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. */