Commit 255d0884 authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds

mm/slub.c: list_lock may not be held in some circumstances

Commit c65c1877 ("slub: use lockdep_assert_held") incorrectly
required that add_full() and remove_full() hold n->list_lock.  The lock
is only taken when kmem_cache_debug(s), since that's the only time it
actually does anything.

Require that the lock only be taken under such a condition.
Reported-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Tested-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Tested-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: default avatarChristoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bd180b4e
...@@ -1004,21 +1004,19 @@ static inline void slab_free_hook(struct kmem_cache *s, void *x) ...@@ -1004,21 +1004,19 @@ static inline void slab_free_hook(struct kmem_cache *s, void *x)
static void add_full(struct kmem_cache *s, static void add_full(struct kmem_cache *s,
struct kmem_cache_node *n, struct page *page) struct kmem_cache_node *n, struct page *page)
{ {
lockdep_assert_held(&n->list_lock);
if (!(s->flags & SLAB_STORE_USER)) if (!(s->flags & SLAB_STORE_USER))
return; return;
lockdep_assert_held(&n->list_lock);
list_add(&page->lru, &n->full); list_add(&page->lru, &n->full);
} }
static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page) static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page)
{ {
lockdep_assert_held(&n->list_lock);
if (!(s->flags & SLAB_STORE_USER)) if (!(s->flags & SLAB_STORE_USER))
return; return;
lockdep_assert_held(&n->list_lock);
list_del(&page->lru); list_del(&page->lru);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment