[Devel] [PATCH RHEL7 COMMIT] ms/mm/slub.c: list_lock may not be held in some circumstances

Konstantin Khorenko khorenko at virtuozzo.com
Fri Nov 25 05:57:46 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.36.1.vz7.20.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.36.1.vz7.20.3
------>
commit 8b5a5e1d36f8d054d38ec5440b699b12bd8cadc3
Author: David Rientjes <rientjes at google.com>
Date:   Tue Nov 15 20:01:57 2016 +0400

    ms/mm/slub.c: list_lock may not be held in some circumstances
    
    Commit c65c1877bd68 ("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 at lwfinger.net>
    Tested-by: Larry Finger <Larry.Finger at lwfinger.net>
    Tested-by: Paul E. McKenney <paulmck at linux.vnet.ibm.com>
    Acked-by: Christoph Lameter <cl at linux.com>
    Cc: Pekka Enberg <penberg at kernel.org>
    Signed-off-by: David Rientjes <rientjes at google.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    
    [backported from ms commit 255d0884f563 ("mm/slub.c: list_lock may not
    be held in some circumstances")]
    
    Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
    Acked-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/slub.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index fe5af7f..0218ecd 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -960,21 +960,19 @@ static void trace(struct kmem_cache *s, struct page *page, void *object,
 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);
 }
 


More information about the Devel mailing list