Skip to content

Commit

Permalink
mm/slub.c: list_lock may not be held in some circumstances
Browse files Browse the repository at this point in the history
Commit c65c187 ("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: Larry Finger <Larry.Finger@lwfinger.net>
Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
David Rientjes authored and Linus Torvalds committed Feb 11, 2014
1 parent bd180b4 commit 255d088
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,21 +1004,19 @@ static inline void slab_free_hook(struct kmem_cache *s, void *x)
static void add_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))
return;

lockdep_assert_held(&n->list_lock);
list_add(&page->lru, &n->full);
}

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))
return;

lockdep_assert_held(&n->list_lock);
list_del(&page->lru);
}

Expand Down

0 comments on commit 255d088

Please sign in to comment.