Re: [PATCH v2 02/10] mm: provide free_reserved_pages(), removing x86 variant

From: Zi Yan

Date: Thu Jul 16 2026 - 17:13:43 EST


On Thu Jul 16, 2026 at 10:51 AM EDT, David Hildenbrand (Arm) wrote:
> Let's extend free_reserved_page() in page_alloc.c to free_reserved_pages(),
> dropping the custom x86 variant. The common-code variant will consume an
> order, so adjust the x86 callers accordingly.
>
> Make free_reserved_pages() assume that we are freeing ordinary
> high-order pages, just with the special "reserved" flavor. The target
> use case for now is freeing vmemmap PMD pages.
>
> Set the refcount directly to 0 (instead of 1) and call
> __free_frozen_pages(). Set the page count to 0 before clearing
> PG_reserved, so someone checking PG_reserved (and not finding it set)
> to then try grabbing a ref would not suddenly have that ref be dropped.
> That is arguably cleaner and safer than the old way of doing it.
>
> Add some kerneldoc. Use a single adjust_managed_page_count() call.
>
> Reviewed-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> Reviewed-by: Muchun Song <muchun.song@xxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> ---
> arch/x86/mm/init_64.c | 8 +-------
> include/linux/mm.h | 8 ++++++--
> mm/page_alloc.c | 33 ++++++++++++++++++++++++++-------
> 3 files changed, 33 insertions(+), 16 deletions(-)
>
LGTM.

Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>


--
Best Regards,
Yan, Zi