linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: chengming.zhou@linux.dev, cl@linux.com
Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com,
	akpm@linux-foundation.org, roman.gushchin@linux.dev,
	42.hyeyoo@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm, slab: remove the corner case of inc_slabs_node()
Date: Fri, 1 Mar 2024 17:03:58 +0100	[thread overview]
Message-ID: <6594a42c-0f53-4124-9177-d1c631d9764f@suse.cz> (raw)
In-Reply-To: <20240222130233.2880176-1-chengming.zhou@linux.dev>

On 2/22/24 14:02, chengming.zhou@linux.dev wrote:
> From: Chengming Zhou <chengming.zhou@linux.dev>
> 
> We already have the inc_slabs_node() after kmem_cache_node->node[node]
> initialized in early_kmem_cache_node_alloc(), this special case of
> inc_slabs_node() can be removed. Then we don't need to consider the
> existence of kmem_cache_node in inc_slabs_node() anymore.
> 
> Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>

Well spotted, thank. Added to slab/for-next.

> ---
>  mm/slub.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 284b751b3b64..3f413e5e1415 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1500,16 +1500,8 @@ static inline void inc_slabs_node(struct kmem_cache *s, int node, int objects)
>  {
>  	struct kmem_cache_node *n = get_node(s, node);
>  
> -	/*
> -	 * May be called early in order to allocate a slab for the
> -	 * kmem_cache_node structure. Solve the chicken-egg
> -	 * dilemma by deferring the increment of the count during
> -	 * bootstrap (see early_kmem_cache_node_alloc).
> -	 */
> -	if (likely(n)) {
> -		atomic_long_inc(&n->nr_slabs);
> -		atomic_long_add(objects, &n->total_objects);
> -	}
> +	atomic_long_inc(&n->nr_slabs);
> +	atomic_long_add(objects, &n->total_objects);
>  }
>  static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects)
>  {
> @@ -4877,7 +4869,6 @@ static void early_kmem_cache_node_alloc(int node)
>  	slab = new_slab(kmem_cache_node, GFP_NOWAIT, node);
>  
>  	BUG_ON(!slab);
> -	inc_slabs_node(kmem_cache_node, slab_nid(slab), slab->objects);
>  	if (slab_nid(slab) != node) {
>  		pr_err("SLUB: Unable to allocate memory from node %d\n", node);
>  		pr_err("SLUB: Allocating a useless per node structure in order to be able to continue\n");



      reply	other threads:[~2024-03-01 16:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 13:02 chengming.zhou
2024-03-01 16:03 ` 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=6594a42c-0f53-4124-9177-d1c631d9764f@suse.cz \
    --to=vbabka@suse.cz \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@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