[PATCH] rcuscale: Drain kfree_call_rcu() callbacks before module unload
From: Zqiang
Date: Wed Dec 02 2026 - 04:21:09 EST
With kfree_rcu_test=1 and kfree_by_call_rcu=1, the kfree-scale threads
queue kfree_call_rcu() callbacks via call_rcu(), and kfree_call_rcu()
lives in module text, kfree_scale_cleanup() stops the threads but not
wait already-queued callbacks, so module unload can free the text while
RCU core still holds references to it. this commit therefore invoke
rcu_barrier() after stopping the threads.
Signed-off-by: Zqiang <qiang.zhang@xxxxxxxxx>
---
kernel/rcu/rcuscale.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
index 681f08e644cc..2cf0bc071aa1 100644
--- a/kernel/rcu/rcuscale.c
+++ b/kernel/rcu/rcuscale.c
@@ -906,6 +906,8 @@ kfree_scale_cleanup(void)
kfree_reader_tasks = NULL;
}
+ if (kfree_by_call_rcu)
+ rcu_barrier();
torture_cleanup_end();
}
@@ -955,12 +957,14 @@ kfree_scale_init(void)
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
+ kfree_by_call_rcu = 0;
firsterr = -1;
goto unwind;
}
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
+ kfree_by_call_rcu = 0;
firsterr = -1;
goto unwind;
}
--
2.17.1