From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
To: linux-kernel@vger.kernel.org
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
byungchul.park@lge.com, Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
rcu@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH v2 -rcu dev 3/5] rcu/tree: Add support for debug_objects debugging for kfree_rcu()
Date: Fri, 30 Aug 2019 12:36:31 -0400 [thread overview]
Message-ID: <20190830163633.104099-4-joel@joelfernandes.org> (raw)
In-Reply-To: <20190830163633.104099-1-joel@joelfernandes.org>
Make use of RCU's debug_objects debugging support
(CONFIG_DEBUG_OBJECTS_RCU_HEAD) similar to call_rcu() and other flavors.
We queue the object during the kfree_rcu() call and dequeue it during
reclaim.
Tested that enabling CONFIG_DEBUG_OBJECTS_RCU_HEAD successfully detects
double kfree_rcu() calls.
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
kernel/rcu/tree.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 2e1772469de9..de13805d1bd0 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2757,6 +2757,7 @@ static void kfree_rcu_work(struct work_struct *work)
for (; head; head = next) {
next = head->next;
/* Could be possible to optimize with kfree_bulk in future */
+ debug_rcu_head_unqueue(head);
__rcu_reclaim(rcu_state.name, head);
cond_resched_tasks_rcu_qs();
}
@@ -2876,6 +2877,13 @@ void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
if (rcu_scheduler_active != RCU_SCHEDULER_RUNNING)
return kfree_call_rcu_nobatch(head, func);
+ if (debug_rcu_head_queue(head)) {
+ /* Probable double kfree_rcu() */
+ WARN_ONCE(1, "kfree_call_rcu(): Double-freed call. rcu_head %p\n",
+ head);
+ return;
+ }
+
head->func = func;
local_irq_save(flags); /* For safely calling this_cpu_ptr(). */
--
2.23.0.187.g17f5b7556c-goog
next prev parent reply other threads:[~2019-08-30 16:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-30 16:36 [PATCH v2 -rcu dev 0/5] kfree_rcu() additions for -rcu Joel Fernandes (Google)
2019-08-30 16:36 ` [PATCH v2 -rcu dev 1/5] rcu/rcuperf: Add kfree_rcu() performance Tests Joel Fernandes (Google)
2019-08-30 16:36 ` [PATCH v2 -rcu dev 2/5] rcu/tree: Add multiple in-flight batches of kfree_rcu work Joel Fernandes (Google)
2019-08-30 16:36 ` Joel Fernandes (Google) [this message]
2019-08-30 16:36 ` [PATCH v2 -rcu dev 4/5] rcu: Remove kfree_rcu() special casing and lazy handling Joel Fernandes (Google)
2019-08-30 16:36 ` [PATCH v2 -rcu dev 5/5] rcu: Remove kfree_call_rcu_nobatch() Joel Fernandes (Google)
2019-09-23 23:49 ` [PATCH v2 -rcu dev 0/5] kfree_rcu() additions for -rcu Paul E. McKenney
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=20190830163633.104099-4-joel@joelfernandes.org \
--to=joel@joelfernandes.org \
--cc=byungchul.park@lge.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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;
as well as URLs for NNTP newsgroup(s).