Re: [PATCH 2/8] mm: percpu: charge obj_exts allocation with __GFP_ACCOUNT
From: Shakeel Butt
Date: Thu May 21 2026 - 13:40:07 EST
On Mon, May 11, 2026 at 10:20:37PM +0200, Alexandre Ghiti wrote:
> This is a preparatory patch for upcoming per-memcg-per-node kmem
> accounting.
>
> pcpu allocations are always fully charged at once using
> pcpu_obj_full_size(), which returns the size of the pcpu "metadata" +
> pcpu "payload". But metadata and payload may not be allocated on the
> same numa node, so charge the metadata independently from the payload.
>
> Do this by explicitly passing __GFP_ACCOUNT to the obj_exts allocation
> and remove its accounting in pcpu_memcg_pre_alloc_hook().
Will all the entries in obj_exts array be for the same memcg? If not then why we
are charging the whole array to the one which happen to allocate the array?
Sorry I don't know the details of percpu allocator, so asking some dumb
questions:
1. Does the alloc_percpu() (& similar functions) allocate the underlying on a
single node or does it allocate memory for each cpu on their local node?
For slub, it is on the same node, so the situation is easier to handle.
2. On a typical system how much memory is consumed by obj_exts for the percpu
allocator chunks? I am wondering if we don't charge it, how much will we
loose?
3. What would be side effect on assuming that obj_exts is on the same node as
the given chunk?