+ slub-introduce-config_slub_rcu_debug-v8.patch added to mm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: slub: Introduce CONFIG_SLUB_RCU_DEBUG
has been added to the -mm mm-unstable branch.  Its filename is
     slub-introduce-config_slub_rcu_debug-v8.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/slub-introduce-config_slub_rcu_debug-v8.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Jann Horn <jannh@xxxxxxxxxx>
Subject: slub: Introduce CONFIG_SLUB_RCU_DEBUG
Date: Fri, 09 Aug 2024 17:36:56 +0200

  - move rcu_barrier() out of locked region (vbabka)
  - rearrange code in slab_free_after_rcu_debug (vbabka)

Link: https://lkml.kernel.org/r/20240809-kasan-tsbrcu-v8-2-aef4593f9532@xxxxxxxxxx
Tested-by: syzbot+263726e59eab6b442723@xxxxxxxxxxxxxxxxxxxxxxxxx
Reviewed-by: Andrey Konovalov <andreyknvl@xxxxxxxxx>
Acked-by: Marco Elver <elver@xxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx> (slab)
Signed-off-by: Jann Horn <jannh@xxxxxxxxxx>
Cc: Alexander Potapenko <glider@xxxxxxxxxx>
Cc: Andrey Ryabinin <ryabinin.a.a@xxxxxxxxx>
Cc: Christoph Lameter <cl@xxxxxxxxx>
Cc: David Rientjes <rientjes@xxxxxxxxxx>
Cc: David Sterba <dsterba@xxxxxxx>
Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Cc: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>
Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
Cc: Pekka Enberg <penberg@xxxxxxxxxx>
Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx>
Cc: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/slab_common.c |   22 +++++++++++++---------
 mm/slub.c        |    5 ++---
 2 files changed, 15 insertions(+), 12 deletions(-)

--- a/mm/slab_common.c~slub-introduce-config_slub_rcu_debug-v8
+++ a/mm/slab_common.c
@@ -576,15 +576,6 @@ void kmem_cache_destroy(struct kmem_cach
 	if (unlikely(!s) || !kasan_check_byte(s))
 		return;
 
-	cpus_read_lock();
-	mutex_lock(&slab_mutex);
-
-	rcu_set = s->flags & SLAB_TYPESAFE_BY_RCU;
-
-	s->refcount--;
-	if (s->refcount)
-		goto out_unlock;
-
 	if (IS_ENABLED(CONFIG_SLUB_RCU_DEBUG) &&
 	    (s->flags & SLAB_TYPESAFE_BY_RCU)) {
 		/*
@@ -593,10 +584,23 @@ void kmem_cache_destroy(struct kmem_cach
 		 * defer their freeing with call_rcu().
 		 * Wait for such call_rcu() invocations here before actually
 		 * destroying the cache.
+		 *
+		 * It doesn't matter that we haven't looked at the slab refcount
+		 * yet - slabs with SLAB_TYPESAFE_BY_RCU can't be merged, so
+		 * the refcount should be 1 here.
 		 */
 		rcu_barrier();
 	}
 
+	cpus_read_lock();
+	mutex_lock(&slab_mutex);
+
+	rcu_set = s->flags & SLAB_TYPESAFE_BY_RCU;
+
+	s->refcount--;
+	if (s->refcount)
+		goto out_unlock;
+
 	err = shutdown_cache(s);
 	WARN(err, "%s %s: Slab cache still has objects when called from %pS",
 	     __func__, s->name, (void *)_RET_IP_);
--- a/mm/slub.c~slub-introduce-config_slub_rcu_debug-v8
+++ a/mm/slub.c
@@ -4563,9 +4563,8 @@ static void slab_free_after_rcu_debug(st
 		return;
 
 	/* resume freeing */
-	if (!slab_free_hook(s, object, slab_want_init_on_free(s), true))
-		return;
-	do_slab_free(s, slab, object, object, 1, _THIS_IP_);
+	if (slab_free_hook(s, object, slab_want_init_on_free(s), true))
+		do_slab_free(s, slab, object, object, 1, _THIS_IP_);
 }
 #endif /* CONFIG_SLUB_RCU_DEBUG */
 
_

Patches currently in -mm which might be from jannh@xxxxxxxxxx are

mm-fix-harmless-type-confusion-in-lock_vma_under_rcu.patch
kasan-catch-invalid-free-before-slub-reinitializes-the-object.patch
slub-introduce-config_slub_rcu_debug.patch
slub-introduce-config_slub_rcu_debug-v8.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux