Re: [RFC PATCH 4/4] mm/percpu: stop unmapping the CPU that failed to map

From: Uladzislau Rezki

Date: Tue Oct 13 2026 - 16:53:51 EST


On Tue, Oct 13, 2026 at 03:46:43PM +0400, Suren Baghdasaryan wrote:
> On Fri, Oct 9, 2026 at 10:36 AM Hao Ge <hao.ge@xxxxxxxxx> wrote:
> >
> > __pcpu_map_pages() clears the PTEs it installed when it fails, so
> > pcpu_map_pages() only has to tear down the CPUs it mapped before
> > the failing one.
> >
> > Signed-off-by: Hao Ge <hao.ge@xxxxxxxxx>
>
> Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
>
>
> > ---
> > mm/percpu-vm.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c
> > index 509d8901835c..59d3a336a6bd 100644
> > --- a/mm/percpu-vm.c
> > +++ b/mm/percpu-vm.c
> > @@ -252,10 +252,11 @@ static int pcpu_map_pages(struct pcpu_chunk *chunk, struct page **pages,
> > return 0;
> > err:
> > for_each_possible_cpu(tcpu) {
> > - __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start),
> > - page_end - page_start);
> > + /* The failing CPU's partial mapping undoes itself */
> > if (tcpu == cpu)
> > break;
> > + __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start),
> > + page_end - page_start);
> > }
> > pcpu_post_unmap_tlb_flush(chunk, page_start, page_end);
> > return err;
> > --
> > 2.25.1
> >
Reviewed-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>

--
Uladzislau Rezki