Re: [PATCH v5 0/3] mm/page_alloc: Batch callers of free_pcppages_bulk
From: Vlastimil Babka
Date: Tue Oct 14 2025 - 13:54:30 EST
On 10/14/25 16:50, Joshua Hahn wrote:
> Changelog
> =========
> v4 --> v5:
> - Wordsmithing
> - Patches 1/3 and 2/3 were left untouched.
> - Patch 3/3 no longer checks for the to_free == 0 case. It also now checks
> for pcp->count > 0 as the condition inside the while loop, and the early
> break checks for the opposite condition. Note that both to_free and
> pcp->count can become negative due to high-order pages that are freed, so
> we must check for (to_free <= 0 || pcp->count <= 0), instead of just
> checking for == 0.
I don't see how that's possible?
- to_free is decremented by to_free_batched = min(to_free, batch); so it
can't go negative.
- pcp->count indeed decrements by nr_pages but it should be exactly zero
once pcp becomes empty. It's true that internally in free_pcppages_bulk()
the count parameter (where we pass to_free_batched) can go negative, but
that doesn't affect to_free_batched in the caller free_frozen_page_commit().
So testing for <= is unnecessary and only looks weird?