All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: sxwjean@me.com
Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	vbabka@suse.cz, roman.gushchin@linux.dev,
	songmuchun@bytedance.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Xiongwei Song <xiongwei.song@windriver.com>
Subject: Re: [PATCH v2] mm/slub: Simplify __kmem_cache_alias()
Date: Sat, 4 Jun 2022 09:42:54 +0000	[thread overview]
Message-ID: <YpspHqZM27DeEhNR@n2.us-central1-a.c.spheric-algebra-350919.internal> (raw)
In-Reply-To: <20220603143555.41914-1-sxwjean@me.com>

On Fri, Jun 03, 2022 at 10:35:55PM +0800, sxwjean@me.com wrote:
> From: Xiongwei Song <xiongwei.song@windriver.com>
> 
> There is no need to do anything if sysfs_slab_alias() return nonzero
> value after getting a mergeable cache.
> 
> Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com>
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
> ---
> v2: Collect Reviewed-by tag from Muchun.
> ---
>  mm/slub.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index d8d5abf49f5f..9444277d669a 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -4861,6 +4861,9 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
>  
>  	s = find_mergeable(size, align, flags, name, ctor);
>  	if (s) {
> +		if (sysfs_slab_alias(s, name))
> +			return NULL;
> +
>  		s->refcount++;
>

I think we should not expose sysfs attributes before initializing
what can be read via sysfs attribute (object_size).

>  		/*
> @@ -4869,11 +4872,6 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
>  		 */
>  		s->object_size = max(s->object_size, size);

this calculation should be done before sysfs_slab_alias().

Thanks,
Hyeonggon

>  		s->inuse = max(s->inuse, ALIGN(size, sizeof(void *)));
> -
> -		if (sysfs_slab_alias(s, name)) {
> -			s->refcount--;
> -			s = NULL;
> -		}
>  	}
>  
>  	return s;
> -- 
> 2.30.2
> 

  reply	other threads:[~2022-06-04  9:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 14:35 [PATCH v2] mm/slub: Simplify __kmem_cache_alias() sxwjean
2022-06-04  9:42 ` Hyeonggon Yoo [this message]
2022-06-05  7:04   ` Xiongwei Song
2022-06-14  8:51     ` Hyeonggon Yoo
2022-06-15  8:37     ` Vlastimil Babka
2022-06-15 11:09       ` Xiongwei Song

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=YpspHqZM27DeEhNR@n2.us-central1-a.c.spheric-algebra-350919.internal \
    --to=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --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 \
    --cc=songmuchun@bytedance.com \
    --cc=sxwjean@me.com \
    --cc=vbabka@suse.cz \
    --cc=xiongwei.song@windriver.com \
    /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.