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: Invoke cur_ops->cleanup() in kfree_scale_cleanup()
Date: Fri, 20 Nov 2026 18:04:53 +0800 [thread overview]
Message-ID: <20261120100453.5826-4-qiang.zhang@linux.dev> (raw)
In-Reply-To: <20261120100453.5826-1-qiang.zhang@linux.dev>
When the kfree_rcu test is selected, rcu_scale_cleanup() delegates to
kfree_scale_cleanup() and returns, so cur_ops->cleanup() is never invoked,
for the srcud and srcua flavors, this fails to release the srcu_struct
which allocated by cur_ops->init().
This commit therefore call cur_ops->cleanup() before kfree_scale_cleanup()
ends, and also guard the cur_ops is not NULL.
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
insmod rcuscale.ko scale_type=srcua kfree_rcu_test=1 gp_exp=1
unreferenced object (percpu) 0x607d981476c0 (size 576):
comm "insmod", pid 1151, jiffies 4294997383
hex dump (first 32 bytes on cpu 11):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc ad6c346):
kmemleak_alloc_percpu+0x89/0xa0
pcpu_alloc_noprof+0x69c/0xd30
init_srcu_struct_fields+0xb45/0x1070
__init_srcu_struct_common+0x4d/0x60
__init_srcu_struct_atomic+0x45/0x70
0xffffffffc060380e
0xffffffffc06071d8
do_one_initcall+0xd9/0x620
do_init_module+0x2b6/0x830
load_module+0x7b5b/0x81d0
init_module_from_file+0x15f/0x180
idempotent_init_module+0x3b1/0x800
__x64_sys_finit_module+0x11a/0x170
x64_sys_call+0x3e0/0x1fb0
do_syscall_64+0xd2/0x750
entry_SYSCALL_64_after_hwframe+0x76/0x7e
kernel/rcu/rcuscale.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
index 5659eaebc5c0..a5644db54119 100644
--- a/kernel/rcu/rcuscale.c
+++ b/kernel/rcu/rcuscale.c
@@ -901,6 +901,8 @@ kfree_scale_cleanup(void)
kfree_reader_tasks = NULL;
}
+ if (cur_ops && cur_ops->cleanup != NULL)
+ cur_ops->cleanup();
torture_cleanup_end();
}
@@ -1036,7 +1038,7 @@ rcu_scale_cleanup(void)
SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!");
// If built-in, just report all of the GP kthread's CPU time.
- if (IS_BUILTIN(CONFIG_RCU_SCALE_TEST) && !kthread_tp && cur_ops->rso_gp_kthread)
+ if (IS_BUILTIN(CONFIG_RCU_SCALE_TEST) && cur_ops && !kthread_tp && cur_ops->rso_gp_kthread)
kthread_tp = cur_ops->rso_gp_kthread();
if (kthread_tp) {
u32 ns;
--
2.17.1
prev parent reply other threads:[~2026-11-20 10:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:04 [PATCH] refscale: Fix possible oops in the typesafe_cleanup() Zqiang
2026-11-20 10:04 ` [PATCH] rcuscale: Handle cur_ops->init() failures for srcu testing Zqiang
2026-11-20 10:04 ` [PATCH] rcuscale: Disable gp_exp when cur_ops->exp_completed is not implemented Zqiang
2026-11-20 10:04 ` Zqiang [this message]
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=20261120100453.5826-4-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