linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Shakeel Butt <shakeelb@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Alexander Potapenko <glider@google.com>,
	Greg Thelen <gthelen@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] slab, slub: skip unnecessary kasan_cache_shutdown()
Date: Tue, 27 Mar 2018 17:16:59 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.20.1803271715310.8944@chino.kir.corp.google.com> (raw)
In-Reply-To: <20180327230603.54721-1-shakeelb@google.com>

On Tue, 27 Mar 2018, Shakeel Butt wrote:

> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index 49fffb0ca83b..135ce2838c89 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -382,7 +382,8 @@ void kasan_cache_shrink(struct kmem_cache *cache)
>  
>  void kasan_cache_shutdown(struct kmem_cache *cache)
>  {
> -	quarantine_remove_cache(cache);
> +	if (!__kmem_cache_empty(cache))
> +		quarantine_remove_cache(cache);
>  }
>  
>  size_t kasan_metadata_size(struct kmem_cache *cache)
> diff --git a/mm/slab.c b/mm/slab.c
> index 9212c64bb705..b59f2cdf28d1 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -2291,6 +2291,18 @@ static int drain_freelist(struct kmem_cache *cache,
>  	return nr_freed;
>  }
>  
> +bool __kmem_cache_empty(struct kmem_cache *s)
> +{
> +	int node;
> +	struct kmem_cache_node *n;
> +
> +	for_each_kmem_cache_node(s, node, n)
> +		if (!list_empty(&n->slabs_full) ||
> +		    !list_empty(&n->slabs_partial))
> +			return false;
> +	return true;
> +}
> +
>  int __kmem_cache_shrink(struct kmem_cache *cachep)
>  {
>  	int ret = 0;
> diff --git a/mm/slab.h b/mm/slab.h
> index e8981e811c45..68bdf498da3b 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -166,6 +166,7 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size,
>  			      SLAB_TEMPORARY | \
>  			      SLAB_ACCOUNT)
>  
> +bool __kmem_cache_empty(struct kmem_cache *);
>  int __kmem_cache_shutdown(struct kmem_cache *);
>  void __kmem_cache_release(struct kmem_cache *);
>  int __kmem_cache_shrink(struct kmem_cache *);
> diff --git a/mm/slub.c b/mm/slub.c
> index 1edc8d97c862..44aa7847324a 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3707,6 +3707,17 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
>  		discard_slab(s, page);
>  }
>  
> +bool __kmem_cache_empty(struct kmem_cache *s)
> +{
> +	int node;
> +	struct kmem_cache_node *n;
> +
> +	for_each_kmem_cache_node(s, node, n)
> +		if (n->nr_partial || slabs_node(s, node))
> +			return false;
> +	return true;
> +}
> +
>  /*
>   * Release all resources used by a slab cache.
>   */

Any reason not to just make quarantine_remove_cache() part of 
__kmem_cache_shutdown() instead of duplicating its logic?

  reply	other threads:[~2018-03-28  0:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 23:06 Shakeel Butt
2018-03-28  0:16 ` David Rientjes [this message]
2018-03-28  5:41   ` Shakeel Butt
2018-03-28 21:29     ` David Rientjes
2018-03-28 17:03 ` Andrey Ryabinin
2018-03-28 22:00 ` Christopher Lameter

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=alpine.DEB.2.20.1803271715310.8944@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=cl@linux.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=gthelen@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox