All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dennis Zhou <dennis@kernel.org>
To: Paul Sherman <shermanpauldylan@gmail.com>
Cc: linux-mm@kvack.org, tj@kernel.org, vbabka@suse.cz,
	dennis@kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH] mm/percpu: allow embed allocator when total size fits in vmalloc
Date: Mon, 20 Jul 2026 07:02:45 -0700	[thread overview]
Message-ID: <al4qhdtunscCLpOG@palisades.local> (raw)
In-Reply-To: <20260719055928.1939-1-shermanpauldylan@gmail.com>

Hello Paul,

On Sat, Jul 18, 2026 at 10:59:28PM -0700, Paul Sherman wrote:
> Andrew,
> 
> Thank you for the encouraging words on the initial submission.
> 
> Tejun,
> 
> Further testing on SG2042 (Sv39, 4 NUMA nodes, 128GB) showed that
> the proposed change allows the embedded first chunk to be created
> successfully, but later dynamic chunk population consistently fails
> in pcpu_populate_chunk(), with warnings originating from
> __vmap_pages_range_noflush(). Reverting the patch eliminates those
> warnings on the same hardware.
> 
> Looking through the code, my current understanding is that dynamic
> chunks inherit the first chunk's layout through the shared
> pcpu_unit_offsets[] table, while vmalloc reservations are driven by
> pcpu_group_offsets[]. That led me to wonder whether I've encountered
> a fundamental allocator invariant rather than merely an implementation
> detail.
> 
> Is the requirement that all chunks share a single pcpu_unit_offsets[]
> layout fundamental to the percpu allocator design, or is there an
> intended mechanism for decoupling the embedded first-chunk layout from
> dynamic chunk vmalloc mappings?
> 

Percpu memory is essentially an offset-based virtual address space. We
build the unit and group offsets when setting up the first chunk at
boot, and those offsets remain fixed for the lifetime of the machine.
Consequently, every later chunk must reproduce the same relative virtual
layout.

The embedded first chunk works because its sparse addresses already
exist in the linear map. However, pcpu_setup_first_chunk() saves that
layout in pcpu_group_offsets, which is subsequently passed to
pcpu_get_vm_areas() when creating dynamic chunks. On this machine the
resulting span is larger than the vmalloc area, so allowing the embedded
setup to succeed means that new dynamic chunks will fail once the first
chunk is exhausted.

Machines have grown considerably since this design was introduced.
Supporting an embedded layout like this would probably require a purely
direct-mapped backend, with congruent physical ranges reserved at boot
for future chunks. That may be reasonable for a particular machine if
percpu growth can be bounded and the reservation is small relative to
available memory, but I don´t think it generalizes based solely on the
ratio between chunk size and total memory. We would also need to
guarantee the required physical placement and decide how much space to
reserve for lifetime percpu growth.

As is, this patch isn't correct, but it might inspire new work.

Thanks,
Dennis

> The answer will help determine whether the correct next step is to
> withdraw the patch and instead document the existing invariant, or
> whether there's a larger design direction worth investigating.
> 
> Thanks,
> Paul


      reply	other threads:[~2026-07-20 14:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 23:16 [PATCH] mm/percpu: allow embed allocator when total size fits in vmalloc Paul Sherman
2026-07-18  0:23 ` Andrew Morton
2026-07-18 17:49   ` Paul Sherman
2026-07-19  5:59 ` Paul Sherman
2026-07-20 14:02   ` Dennis Zhou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=al4qhdtunscCLpOG@palisades.local \
    --to=dennis@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=shermanpauldylan@gmail.com \
    --cc=tj@kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.