Re: [PATCH] mm/percpu-km: fix bitmap overflow and accounting in pcpu_create_chunk()
From: Dennis Zhou
Date: Mon Jul 20 2026 - 18:16:55 EST
Hi Zi,
On Mon, Jul 20, 2026 at 03:20:31PM -0400, Zi Yan wrote:
> On Thu Jul 9, 2026 at 3:12 PM EDT, Zi Yan wrote:
> > In pcpu_create_chunk(), nr_pages is the total contiguous backing
> > allocation, i.e., nr_units * pcpu_unit_pages, but pcpu_chunk_populated()
> > uses it to set chunk->populated, whose size is pcpu_unit_pages, bitmap.
> > Since bit N in chunk->populated means page offset N inside every unit is
> > backed. When nr_units > 1, the function writes beyond chunk->populated. Fix
> > it by using chunk->nr_pages.
> >
> > It also fixes the global pcpu_nr_empty_pop_pages accounting, since
> > pcpu_balance_free() only iterates up to chunk->nr_pages.
> >
> > Commit a63d4ac4ab609 ("percpu: make percpu-km set chunk->populated bitmap
> > properly") introduced the bitmap overflow issue. Later,
> > commit b539b87fed37f ("percpu: implmeent pcpu_nr_empty_pop_pages and
> > chunk->nr_populated") added pcpu_nr_empty_pop_pages and caused the
> > accounting issue.
>
> A gentle ping on this patch. It would be great to get some feedback.
> Thanks.
>
Sorry, this is right and I missed it years ago.
Acked-by: Dennis Zhou <dennis@xxxxxxxxxx>
Thanks,
Dennis