Skip to content

Commit 255d088

Browse files
rientjestorvalds
authored andcommitted
mm/slub.c: list_lock may not be held in some circumstances
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>
1 parent bd180b4 commit 255d088

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mm/slub.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,21 +1004,19 @@ static inline void slab_free_hook(struct kmem_cache *s, void *x)
10041004
static void add_full(struct kmem_cache *s,
10051005
struct kmem_cache_node *n, struct page *page)
10061006
{
1007-
lockdep_assert_held(&n->list_lock);
1008-
10091007
if (!(s->flags & SLAB_STORE_USER))
10101008
return;
10111009

1010+
lockdep_assert_held(&n->list_lock);
10121011
list_add(&page->lru, &n->full);
10131012
}
10141013

10151014
static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page)
10161015
{
1017-
lockdep_assert_held(&n->list_lock);
1018-
10191016
if (!(s->flags & SLAB_STORE_USER))
10201017
return;
10211018

1019+
lockdep_assert_held(&n->list_lock);
10221020
list_del(&page->lru);
10231021
}
10241022

0 commit comments

Comments
 (0)