aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorYe Liu <liuye@kylinos.cn>2025-08-14 17:00:52 +0800
committerAndrew Morton <akpm@linux-foundation.org>2025-09-13 16:55:02 -0700
commit0c04015d45e6f102e14bde69b05a0a0591923248 (patch)
tree67762eac380bd06e3bfe7f4d453869af1457d228 /mm/page_alloc.c
parentselftests/damon/access_memory_even: remove unused header file (diff)
downloadwireguard-linux-0c04015d45e6f102e14bde69b05a0a0591923248.tar.xz
wireguard-linux-0c04015d45e6f102e14bde69b05a0a0591923248.zip
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>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 09241bb7663e..fd55ca824c47 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6236,16 +6236,13 @@ static void calculate_totalreserve_pages(void)
unsigned long managed_pages = zone_managed_pages(zone);
/* 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];
- }
+ for (j = i; j < MAX_NR_ZONES; j++)
+ max = max(max, zone->lowmem_reserve[j]);
/* we treat the high watermark as reserved pages. */
max += high_wmark_pages(zone);
- if (max > managed_pages)
- max = managed_pages;
+ max = min_t(unsigned long, max, managed_pages);
pgdat->totalreserve_pages += max;