From 8a37aeefab0936241b696298d0861e35162a0b54 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Sun, 6 Oct 2024 17:47:02 +0300 Subject: [PATCH] LU-18334 obdclass: wait for RCU completion in lu_kmem_fini(), otherwise otherwise those RCU callbacks doing kmem_cache_free() can race with kmem_cache_destroy(): kmem_cache_destroy echo_object_kmem: Slab cache still has objects WARNING: CPU: 1 PID: 7991 at mm/slab_common.c:523 kmem_cache_destroy Signed-off-by: Alex Zhuravlev Change-Id: I21dfc034b9fc9368bf22d269d6986297a6812a5c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56593 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/obdclass/lu_object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index ecc3094..0ed30a6 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -2293,6 +2293,8 @@ EXPORT_SYMBOL(lu_kmem_init); */ void lu_kmem_fini(struct lu_kmem_descr *caches) { + /* wait for all RCU callbacks freeing objects are done */ + rcu_barrier(); for (; caches->ckd_cache != NULL; ++caches) { if (*caches->ckd_cache != NULL) { kmem_cache_destroy(*caches->ckd_cache); -- 1.8.3.1