Re: [PATCH v2 1/5] mm/percpu-km: clear page->private before free them

From: David Hildenbrand (Arm)

Date: Mon Jul 06 2026 - 04:39:22 EST


On 7/3/26 15:47, Zi Yan wrote:
> page->private is cleared in free page path. In a subsequent commit,
> tail_page->private will be checked and ensured to be zero. Clearing
> percpu-km allocated pages' ->private to prevent triggering warnings later.
>
> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
> ---
> mm/percpu-km.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/mm/percpu-km.c b/mm/percpu-km.c
> index 4efa74a495cb6..7ffe84adadb9d 100644
> --- a/mm/percpu-km.c
> +++ b/mm/percpu-km.c
> @@ -94,8 +94,15 @@ static void pcpu_destroy_chunk(struct pcpu_chunk *chunk)
> pcpu_stats_chunk_dealloc();
> trace_percpu_destroy_chunk(chunk->base_addr);
>
> - if (chunk->data)
> + if (chunk->data) {
> + struct page *pages = (struct page *)chunk->data;
> + int i;
> +
> + /* clear chunk info from each page before free them */
> + for (i = 0; i < nr_pages; i++)
> + pcpu_set_page_chunk(pages + i, NULL);
> __free_pages(chunk->data, order_base_2(nr_pages));
> + }
> pcpu_free_chunk(chunk);
> }
>
>

Un-doing what we did in pcpu_create_chunk.

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David