Skip to content

Commit 6ca0292

Browse files
qiangzh3paulmckrcu
authored andcommitted
rcu: Make tiny RCU support leak callbacks for debug-object errors
Currently, only Tree RCU leaks callbacks setting when it detects a duplicate call_rcu(). This commit causes Tiny RCU to also leak callbacks in this situation. Because this is Tiny RCU, kernel size is important: 1. CONFIG_TINY_RCU=y and CONFIG_DEBUG_OBJECTS_RCU_HEAD=n (Production kernel) Original: text data bss dec hex filename 26290663 20159823 15212544 61663030 3ace736 vmlinux With this commit: text data bss dec hex filename 26290663 20159823 15212544 61663030 3ace736 vmlinux 2. CONFIG_TINY_RCU=y and CONFIG_DEBUG_OBJECTS_RCU_HEAD=y (Debugging kernel) Original: text data bss dec hex filename 26291319 20160143 15212544 61664006 3aceb06 vmlinux With this commit: text data bss dec hex filename 26291319 20160431 15212544 61664294 3acec26 vmlinux These results show that the kernel size is unchanged for production kernels, as desired. Signed-off-by: Zqiang <qiang1.zhang@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent fcb42c9 commit 6ca0292

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

kernel/rcu/tiny.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,31 @@ void synchronize_rcu(void)
158158
}
159159
EXPORT_SYMBOL_GPL(synchronize_rcu);
160160

161+
static void tiny_rcu_leak_callback(struct rcu_head *rhp)
162+
{
163+
}
164+
161165
/*
162166
* Post an RCU callback to be invoked after the end of an RCU grace
163167
* period. But since we have but one CPU, that would be after any
164168
* quiescent state.
165169
*/
166170
void call_rcu(struct rcu_head *head, rcu_callback_t func)
167171
{
172+
static atomic_t doublefrees;
168173
unsigned long flags;
169174

170-
debug_rcu_head_queue(head);
175+
if (debug_rcu_head_queue(head)) {
176+
if (atomic_inc_return(&doublefrees) < 4) {
177+
pr_err("%s(): Double-freed CB %p->%pS()!!! ", __func__, head, head->func);
178+
mem_dump_obj(head);
179+
}
180+
181+
if (!__is_kvfree_rcu_offset((unsigned long)head->func))
182+
WRITE_ONCE(head->func, tiny_rcu_leak_callback);
183+
return;
184+
}
185+
171186
head->func = func;
172187
head->next = NULL;
173188

0 commit comments

Comments
 (0)