All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov@virtuozzo.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: linux-kernel@vger.kernel.org, Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dmitry Safonov <dsafonov@virtuozzo.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Dave Gordon <david.s.gordon@intel.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm/slub: Run free_partial() outside of the kmem_cache_node->list_lock
Date: Tue, 9 Aug 2016 18:17:43 +0300	[thread overview]
Message-ID: <20160809151743.GF1983@esperanza> (raw)
In-Reply-To: <1470753992-8114-1-git-send-email-chris@chris-wilson.co.uk>

On Tue, Aug 09, 2016 at 03:46:32PM +0100, Chris Wilson wrote:
...
> diff --git a/mm/slub.c b/mm/slub.c
> index 850737bdfbd8..22b2c1f3db0e 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3629,11 +3629,15 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
>   */
>  static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
>  {
> +	LIST_HEAD(partial_list);
>  	struct page *page, *h;
>  
>  	BUG_ON(irqs_disabled());
>  	spin_lock_irq(&n->list_lock);
> -	list_for_each_entry_safe(page, h, &n->partial, lru) {
> +	list_splice_init(&n->partial, &partial_list);
> +	spin_unlock_irq(&n->list_lock);
> +
> +	list_for_each_entry_safe(page, h, &partial_list, lru) {
>  		if (!page->inuse) {
>  			remove_partial(n, page);

remove_partial() must be called with n->list_lock held - it even has
lockdep_assert_held(). What you actually need to do is to move
discard_slab() out of the critical section, like __kmem_cache_shrink()
does.

>  			discard_slab(s, page);
> @@ -3642,7 +3646,6 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
>  			"Objects remaining in %s on __kmem_cache_shutdown()");
>  		}
>  	}
> -	spin_unlock_irq(&n->list_lock);
>  }
>  
>  /*

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Davydov <vdavydov@virtuozzo.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: <linux-kernel@vger.kernel.org>, Christoph Lameter <cl@linux.com>,
	"Pekka Enberg" <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	"Joonsoo Kim" <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dmitry Safonov <dsafonov@virtuozzo.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Dave Gordon <david.s.gordon@intel.com>, <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/slub: Run free_partial() outside of the kmem_cache_node->list_lock
Date: Tue, 9 Aug 2016 18:17:43 +0300	[thread overview]
Message-ID: <20160809151743.GF1983@esperanza> (raw)
In-Reply-To: <1470753992-8114-1-git-send-email-chris@chris-wilson.co.uk>

On Tue, Aug 09, 2016 at 03:46:32PM +0100, Chris Wilson wrote:
...
> diff --git a/mm/slub.c b/mm/slub.c
> index 850737bdfbd8..22b2c1f3db0e 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3629,11 +3629,15 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
>   */
>  static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
>  {
> +	LIST_HEAD(partial_list);
>  	struct page *page, *h;
>  
>  	BUG_ON(irqs_disabled());
>  	spin_lock_irq(&n->list_lock);
> -	list_for_each_entry_safe(page, h, &n->partial, lru) {
> +	list_splice_init(&n->partial, &partial_list);
> +	spin_unlock_irq(&n->list_lock);
> +
> +	list_for_each_entry_safe(page, h, &partial_list, lru) {
>  		if (!page->inuse) {
>  			remove_partial(n, page);

remove_partial() must be called with n->list_lock held - it even has
lockdep_assert_held(). What you actually need to do is to move
discard_slab() out of the critical section, like __kmem_cache_shrink()
does.

>  			discard_slab(s, page);
> @@ -3642,7 +3646,6 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
>  			"Objects remaining in %s on __kmem_cache_shutdown()");
>  		}
>  	}
> -	spin_unlock_irq(&n->list_lock);
>  }
>  
>  /*

  reply	other threads:[~2016-08-09 15:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 14:46 [PATCH] mm/slub: Run free_partial() outside of the kmem_cache_node->list_lock Chris Wilson
2016-08-09 14:46 ` Chris Wilson
2016-08-09 15:17 ` Vladimir Davydov [this message]
2016-08-09 15:17   ` Vladimir Davydov
2016-08-09 15:27   ` [PATCH v2] " Chris Wilson
2016-08-09 15:27     ` Chris Wilson
2016-08-09 15:45     ` Vladimir Davydov
2016-08-09 15:45       ` Vladimir Davydov
2016-08-09 15:52       ` Chris Wilson
2016-08-09 15:52         ` Chris Wilson
2016-08-09 16:06         ` Vladimir Davydov
2016-08-09 16:06           ` Vladimir Davydov
2016-08-09 16:11     ` [PATCH v3] " Chris Wilson
2016-08-09 16:11       ` Chris Wilson
2016-08-09 16:21       ` Christoph Lameter
2016-08-09 16:21         ` Christoph 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=20160809151743.GF1983@esperanza \
    --to=vdavydov@virtuozzo.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=cl@linux.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=david.s.gordon@intel.com \
    --cc=dsafonov@virtuozzo.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 \
    /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.