From: Zqiang <qiang.zhang@linux.dev>
To: paulmck@kernel.org, frederic@kernel.org,
neeraj.upadhyay@kernel.org, joelagnelf@nvidia.com,
urezki@gmail.com, boqun@kernel.org
Cc: qiang.zhang@linux.dev, rcu@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] rcuscale: Drain kfree_call_rcu() callbacks before module unload
Date: Wed, 2 Dec 2026 17:20:56 +0800 [thread overview]
Message-ID: <20261202092056.18334-1-qiang.zhang@linux.dev> (raw)
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
reply other threads:[~2026-12-02 9:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202092056.18334-1-qiang.zhang@linux.dev \
--to=qiang.zhang@linux.dev \
--cc=boqun@kernel.org \
--cc=frederic@kernel.org \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=urezki@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®