From: Zi Yan <ziy@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ye Liu <ye.liu@linux.dev>, 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,
Mel Gorman <mgorman@techsingularity.net>
Subject: Re: [PATCH v3] mm/page_alloc: simplify lowmem_reserve max calculation
Date: Sat, 16 Aug 2025 07:42:33 -0400 [thread overview]
Message-ID: <8A6CFFC7-36D2-4E79-87C4-580C31694F78@nvidia.com> (raw)
In-Reply-To: <20250816002742.5582d91edc4905e3af69480e@linux-foundation.org>
On 16 Aug 2025, at 3:27, Andrew Morton wrote:
> On Fri, 15 Aug 2025 10:45:09 +0800 Ye Liu <ye.liu@linux.dev> 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.
>>
>> ...
>>
>> --- 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;
>> + max = min_t(unsigned long, max, managed_pages);
>>
>
> Use of max_t/min_t is usually a sign that we messed up the type choices
> somewhere.
>
> In this case, I'd say that zone.lowmem_reserve[] should have been
> ulong. Oh well.
It was, but then changed into long because in __zone_watermark_ok() it is compared
to can-be-negative free_pages (see commit 3484b2de9499). Maybe it is better to revert
that change and convert ulong lowmem_reserve to long in __zone_watermark_ok()
for the comparison.
+Mel, for his opinion on it, since he made the change in 3484b2de9499.
--
Best Regards,
Yan, Zi
prev parent reply other threads:[~2025-08-16 11:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 2:45 Ye Liu
2025-08-15 6:43 ` Wei Yang
2025-08-16 7:27 ` Andrew Morton
2025-08-16 11:42 ` Zi Yan [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=8A6CFFC7-36D2-4E79-87C4-580C31694F78@nvidia.com \
--to=ziy@nvidia.com \
--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=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ye.liu@linux.dev \
/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