From: Ye Liu <ye.liu@linux.dev>
To: Zi Yan <ziy@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>, Ye Liu <liuye@kylinos.cn>,
Johannes Weiner <hannes@cmpxchg.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/page_alloc: simplify lowmem_reserve max calculation
Date: Fri, 15 Aug 2025 10:41:16 +0800 [thread overview]
Message-ID: <be1a8882-fb43-4038-a500-01c3e1a6d577@linux.dev> (raw)
In-Reply-To: <E5434A0E-3125-48C7-BD25-185CDA4D9FAC@nvidia.com>
在 2025/8/15 10:36, Zi Yan 写道:
> On 14 Aug 2025, at 22:34, Ye Liu wrote:
>
>> From: Ye Liu <liuye@kylinos.cn>
>>
>> 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.
>>
>> Signed-off-by: Ye Liu <liuye@kylinos.cn>
>> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
>> Acked-by: Zi Yan <ziy@nvidia.com>
>>
>> Changes in v2:
>> - Drop unnecessary braces
>> - Replace "if (max > managed_pages)" with min_t()
>> - Link to v1:https://lore.kernel.org/all/20250814090053.22241-1-ye.liu@linux.dev/
>> ---
>> mm/page_alloc.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 64872214bc7d..2617fd2f4b73 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -6235,16 +6235,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;
>> + min_t(unsigned long, max, managed_pages);
>
> Should be
>
> max = min_t(unsigned long, max, managed_pages);
>
> ;)
Haha I forgot to git add after I modified it ;)
>
>>
>> pgdat->totalreserve_pages += max;
>>
>> --
>> 2.43.0
>
>
> Best Regards,
> Yan, Zi
--
Thanks,
Ye Liu
prev parent reply other threads:[~2025-08-15 2:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 2:34 [PATCH v2] mm/page_alloc: simplify lowmem_reserve max calculation Ye Liu
2025-08-15 2:36 ` Zi Yan
2025-08-15 2:41 ` Ye Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be1a8882-fb43-4038-a500-01c3e1a6d577@linux.dev \
--to=ye.liu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).