linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	 Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Vlastimil Babka <vbabka@suse.cz>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	 Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] slab: Warn on duplicate cache names when DEBUG_VM=y
Date: Sun, 11 Aug 2024 13:30:27 -0700 (PDT)	[thread overview]
Message-ID: <cdfc5a08-c0ee-30a3-d6c5-22d4cfddc3a4@google.com> (raw)
In-Reply-To: <20240807090746.2146479-1-pedro.falcato@gmail.com>

On Wed, 7 Aug 2024, Pedro Falcato wrote:

> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 40b582a014b..1abe6a577d5 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -88,6 +88,19 @@ unsigned int kmem_cache_size(struct kmem_cache *s)
>  EXPORT_SYMBOL(kmem_cache_size);
>  
>  #ifdef CONFIG_DEBUG_VM
> +
> +static bool kmem_cache_is_duplicate_name(const char *name)
> +{
> +	struct kmem_cache *s;
> +
> +	list_for_each_entry(s, &slab_caches, list) {
> +		if (!strcmp(s->name, name))
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  static int kmem_cache_sanity_check(const char *name, unsigned int size)
>  {
>  	if (!name || in_interrupt() || size > KMALLOC_MAX_SIZE) {
> @@ -95,6 +108,11 @@ static int kmem_cache_sanity_check(const char *name, unsigned int size)
>  		return -EINVAL;
>  	}
>  
> +	if (kmem_cache_is_duplicate_name(name)) {
> +		/* Duplicate names will confuse slabtop, et al */
> +		pr_warn("%s: name %s already exists as a cache\n", __func__, name);


Shouldn't this be a full WARN_ON() instead of pr_warn()?  I assume we'll 
be interested in who is adding the cache when the name already exists.


       reply	other threads:[~2024-08-11 20:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240807090746.2146479-1-pedro.falcato@gmail.com>
2024-08-11 20:30 ` David Rientjes [this message]
2024-08-11 22:28   ` Pedro Falcato
2024-08-12  0:55     ` David Rientjes
2024-08-16 12:17       ` Pedro Falcato
2024-08-26 19:23         ` Vlastimil Babka

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=cdfc5a08-c0ee-30a3-d6c5-22d4cfddc3a4@google.com \
    --to=rientjes@google.com \
    --cc=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=pedro.falcato@gmail.com \
    --cc=penberg@kernel.org \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    /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