Skip to content

Commit e5feb1e

Browse files
shreyasbptorvalds
authored andcommitted
tracing/mm: don't trace kmem_cache_free on offline cpus
Since tracepoints use RCU for protection, they must not be called on offline cpus. trace_kmem_cache_free can be called on an offline cpu in this scenario caught by LOCKDEP: =============================== [ INFO: suspicious RCU usage. ] 4.1.0-rc1+ #9 Not tainted ------------------------------- include/trace/events/kmem.h:148 suspicious rcu_dereference_check() usage! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 1, debug_locks = 1 no locks held by swapper/1/0. stack backtrace: CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.1.0-rc1+ #9 Call Trace: .dump_stack+0x98/0xd4 (unreliable) .lockdep_rcu_suspicious+0x108/0x170 .kmem_cache_free+0x344/0x4b0 .__mmdrop+0x4c/0x160 .idle_task_exit+0xf0/0x100 .pnv_smp_cpu_kill_self+0x58/0x2c0 .cpu_die+0x34/0x50 .arch_cpu_idle_dead+0x20/0x40 .cpu_startup_entry+0x708/0x7a0 .start_secondary+0x36c/0x3a0 start_secondary_prolog+0x10/0x14 Fix this by converting kmem_cache_free trace point into TRACE_EVENT_CONDITION where condition is cpu_online(smp_processor_id()) Signed-off-by: Shreyas B. Prabhu <[email protected]> Reported-by: Aneesh Kumar K.V <[email protected]> Reviewed-by: Preeti U Murthy <[email protected]> Acked-by: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent de18246 commit e5feb1e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

include/trace/events/kmem.h

+13-2
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,22 @@ DEFINE_EVENT(kmem_free, kfree,
140140
TP_ARGS(call_site, ptr)
141141
);
142142

143-
DEFINE_EVENT(kmem_free, kmem_cache_free,
143+
DEFINE_EVENT_CONDITION(kmem_free, kmem_cache_free,
144144

145145
TP_PROTO(unsigned long call_site, const void *ptr),
146146

147-
TP_ARGS(call_site, ptr)
147+
TP_ARGS(call_site, ptr),
148+
149+
/*
150+
* This trace can be potentially called from an offlined cpu.
151+
* Since trace points use RCU and RCU should not be used from
152+
* offline cpus, filter such calls out.
153+
* While this trace can be called from a preemptable section,
154+
* it has no impact on the condition since tasks can migrate
155+
* only from online cpus to other online cpus. Thus its safe
156+
* to use raw_smp_processor_id.
157+
*/
158+
TP_CONDITION(cpu_online(raw_smp_processor_id()))
148159
);
149160

150161
TRACE_EVENT(mm_page_free,

0 commit comments

Comments
 (0)