Skip to content

Commit 0c04015

Browse files
qiyeliuakpm00
authored andcommitted
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. [liuye@kylinos.cn: fix layout, use min_t] Link: https://lkml.kernel.org/r/20250815024509.37900-1-ye.liu@linux.dev 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>
1 parent a3f451a commit 0c04015

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

mm/page_alloc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6236,16 +6236,13 @@ static void calculate_totalreserve_pages(void)
62366236
unsigned long managed_pages = zone_managed_pages(zone);
62376237

62386238
/* Find valid and maximum lowmem_reserve in the zone */
6239-
for (j = i; j < MAX_NR_ZONES; j++) {
6240-
if (zone->lowmem_reserve[j] > max)
6241-
max = zone->lowmem_reserve[j];
6242-
}
6239+
for (j = i; j < MAX_NR_ZONES; j++)
6240+
max = max(max, zone->lowmem_reserve[j]);
62436241

62446242
/* we treat the high watermark as reserved pages. */
62456243
max += high_wmark_pages(zone);
62466244

6247-
if (max > managed_pages)
6248-
max = managed_pages;
6245+
max = min_t(unsigned long, max, managed_pages);
62496246

62506247
pgdat->totalreserve_pages += max;
62516248

0 commit comments

Comments
 (0)