Re: [PATCH] mm/page_alloc: optimize lowmem_reserve max lookup using monotonicity

From: Zi Yan

Date: Fri Nov 14 2025 - 11:12:21 EST


On 14 Nov 2025, at 7:36, Brendan Jackman wrote:

> On Fri Nov 14, 2025 at 10:40 AM UTC, fujunjie wrote:
>> Although this code is not on a hot path, the revised form is clearer
>
> Is it...?
>
> If people do think it is clearer, let's at least write the right comment
> in the right place. Instead of having one piece of code
> (calculate_totalreserve_pages()) describe at a distance the behaviour of
> another piece of code (setup_per_zone_lowmem_reserve()), let's describe
> an invariant of the data ("lowmem_reserve is monotonic, up to the first
> zero value"), at the site where the data is defined.

I agree.

>
> I know sometimes in code this complex we do need these
> "spooky-action-at-a-distance" comments but this doesn't seem like one of
> those places to me.

My concern on this change is that the correctness of
calculate_totalreserve_pages() now relies on the implementation of
setup_per_zone_lowmem_reserve(). How can we make sure in the future
this will not break when setup_per_zone_lowmem_reserve() is changed?
Hoping people read the comment and do the right thing?

Best Regards,
Yan, Zi