linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	bpf@vger.kernel.org, linux-mm@kvack.org
Cc: harry.yoo@oracle.com, shakeel.butt@linux.dev, mhocko@suse.com,
	bigeasy@linutronix.de, andrii@kernel.org, memxor@gmail.com,
	akpm@linux-foundation.org, peterz@infradead.org,
	rostedt@goodmis.org, hannes@cmpxchg.org
Subject: Re: [PATCH slab] slab: Clarify comments regarding pfmemalloc and NUMA preferences
Date: Tue, 16 Sep 2025 12:21:25 +0200	[thread overview]
Message-ID: <ef34e217-580d-4d91-9bfb-4db1699e249a@suse.cz> (raw)
In-Reply-To: <20250916014609.47273-1-alexei.starovoitov@gmail.com>

On 9/16/25 03:46, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
> 
> Clarify comments regarding pfmemalloc and NUMA preferences
> when ___slab_alloc() operating in !allow_spin mode.
> 
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Folding that into "slab: Introduce kmalloc_nolock() and kfree_nolock()." in
slab/for-next, thanks.

> ---
>  mm/slub.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 83983de948f3..c995f3bec69d 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -4456,9 +4456,17 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
>  		/*
>  		 * same as above but node_match() being false already
>  		 * implies node != NUMA_NO_NODE.
> -		 * Reentrant slub cannot take locks necessary to
> -		 * deactivate_slab, hence ignore node preference.
> -		 * kmalloc_nolock() doesn't allow __GFP_THISNODE.
> +		 *
> +		 * We don't strictly honor pfmemalloc and NUMA preferences
> +		 * when !allow_spin because:
> +		 *
> +		 * 1. Most kmalloc() users allocate objects on the local node,
> +		 *    so kmalloc_nolock() tries not to interfere with them by
> +		 *    deactivating the cpu slab.
> +		 *
> +		 * 2. Deactivating due to NUMA or pfmemalloc mismatch may cause
> +		 *    unnecessary slab allocations even when n->partial list
> +		 *    is not empty.
>  		 */
>  		if (!node_isset(node, slab_nodes) ||
>  		    !allow_spin) {
> @@ -4547,11 +4555,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
>  		slab = slub_percpu_partial(c);
>  		slub_set_percpu_partial(c, slab);
>  
> -		/*
> -		 * Reentrant slub cannot take locks necessary for
> -		 * __put_partials(), hence ignore node preference.
> -		 * kmalloc_nolock() doesn't allow __GFP_THISNODE.
> -		 */
>  		if (likely(node_match(slab, node) &&
>  			   pfmemalloc_match(slab, gfpflags)) ||
>  		    !allow_spin) {



      reply	other threads:[~2025-09-16 10:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16  1:46 Alexei Starovoitov
2025-09-16 10:21 ` Vlastimil Babka [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=ef34e217-580d-4d91-9bfb-4db1699e249a@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=harry.yoo@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=memxor@gmail.com \
    --cc=mhocko@suse.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shakeel.butt@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox