From: Hao Li <hao.li@linux.dev>
To: Harry Yoo <harry@kernel.org>
Cc: vbabka@kernel.org, akpm@linux-foundation.org, cl@gentwo.org,
rientjes@google.com, roman.gushchin@linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/slub: deduplicate NUMA policy calculation in allocation paths
Date: Wed, 24 Jun 2026 16:17:27 +0800 [thread overview]
Message-ID: <ajuSNGf9aZyyS4mx@fedora> (raw)
In-Reply-To: <0c69b68d-7c67-4d3a-9f90-86a56bc229e7@kernel.org>
On Wed, Jun 24, 2026 at 02:14:55PM +0900, Harry Yoo wrote:
>
>
> On 6/23/26 8:04 PM, Hao Li wrote:
> > Currently, alloc_from_pcs() and __slab_alloc_node() both calculate the
> > NUMA policy independently. Since they are called consecutively in paths
> > like __kmalloc_nolock_noprof() and slab_alloc_node(), this leads to
> > redundant code snippets.
>
> Right.
>
> > Introduce a helper function to resolve the NUMA policy once, eliminating
> > the duplicated code and reducing execution overhead.
>
> Nice.
>
> > Also remove __slab_alloc_node() function because it is almost empty.
>
> Nice!
>
> > The callers of __slab_alloc_node now call ___slab_alloc() directly.
> >
> > Additional notes:
> >
> > Previously, when slab_strict_numa was enabled, alloc_from_pcs() and
> > __slab_alloc_node() could each resolve the task mempolicy, so
> > MPOL_INTERLEAVE or MPOL_WEIGHTED_INTERLEAVE could advance the
> > interleave state twice for a single object allocation attempt.
> >
> > With this change, the strict NUMA node is resolved once and reused by
> > both alloc_from_pcs() and ___slab_alloc().
>
> Nice catch!
>
> > This is a behavior change, but it better matches the intent of
> > selecting one policy node for one allocation attempt.
>
> Right.
>
> and I think backporting is unnecessary here.
>
> > Signed-off-by: Hao Li <hao.li@linux.dev>
> > ---
> > Changes in v2:
> > * Use a better function name apply_strict_numa_policy() (Thanks Harry)
> > * Remove almost empty function __slab_alloc_node.
> > * Add a local variable, strict_node, so the retry path in
> > __kmalloc_nolock_noprof() computes the strict NUMA node from the original
> > node parameter instead of a previously resolved node value.
>
> What about overriding 'node' before retry label instead?
>
> node = apply_strict_numa_policy(node);
> [...]
> retry:
> [...]
>
I agree! I originally used a separate strict_node variable mostly to keep the
old retry behavior intact. But looking at it now, the retry is really just an
internal fallback for the same requested object allocation. There's no strong
reason to advance the MPOL_INTERLEAVE or MPOL_WEIGHTED_INTERLEAVE state again
on each retry.
> Otherwise LGTM.
Thanks!
--
Thanks,
Hao
prev parent reply other threads:[~2026-06-24 8:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 11:04 [PATCH v2] mm/slub: deduplicate NUMA policy calculation in allocation paths Hao Li
2026-06-24 5:14 ` Harry Yoo
2026-06-24 8:17 ` Hao Li [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=ajuSNGf9aZyyS4mx@fedora \
--to=hao.li@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=harry@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@kernel.org \
/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.