The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] rcuscale: Drain kfree_call_rcu() callbacks before module unload
@ 2026-12-02  9:20 Zqiang
  0 siblings, 0 replies; only message in thread
From: Zqiang @ 2026-12-02  9:20 UTC (permalink / raw)
  To: paulmck, frederic, neeraj.upadhyay, joelagnelf, urezki, boqun
  Cc: qiang.zhang, rcu, linux-kernel

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@linux.dev>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02  9:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  9:20 [PATCH] rcuscale: Drain kfree_call_rcu() callbacks before module unload Zqiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox