Skip to content

Commit 4e02370

Browse files
committed
Merge tag 'trace-fixes-v3.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull ftrace fixes from Steven Rostedt: "During testing Sedat Dilek hit a "suspicious RCU usage" splat that pointed out a real bug. During suspend and resume the tlb_flush tracepoint is called when the CPU is going offline. As the CPU has been noted as offline, RCU is ignoring that CPU, which means that it can not use RCU protected locks. When tracepoints are activated, they require RCU locking, and if RCU is ignoring a CPU that runs a tracepoint, there is a chance that the tracepoint could cause corruption. The solution was to change the tracepoint into a TRACE_EVENT_CONDITION() which allows us to check a condition to determine if the tracepoint should be called or not. If the condition is not met, the rcu protected code will not be executed. By adding the condition "cpu_online(smp_processor_id())", this will prevent the RCU protected code from being executed if the CPU is marked offline. After adding this, another bug was discovered. As RCU checks rcu callers, if a rcu call is not done, there is no check (obviously). We found that tracepoints could be added in RCU ignored locations and not have lockdep complain until the tracepoint is activated. This missed places where tracepoints were added in places they should not have been. To fix this, code was added in 3.18 that if lockdep is enabled, any tracepoint will still call the rcu checks even if the tracepoint is not enabled. The bug here, is that the check does not take the CONDITION into account. As the condition may prevent tracepoints from being activated in RCU ignored areas (as the one patch does), we get false positives when we enable lockdep and hit a tracepoint that the condition prevents it from being called in a RCU ignored location. The fix for this is to add the CONDITION to the rcu checks, even if the tracepoint is not enabled" * tag 'trace-fixes-v3.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: x86/tlb/trace: Do not trace on CPU that is offline tracing: Add condition check to RCU lockdep checks
2 parents 0b1ce1a + 6c8465a commit 4e02370

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

include/linux/tracepoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ extern void syscall_unregfunc(void);
173173
TP_PROTO(data_proto), \
174174
TP_ARGS(data_args), \
175175
TP_CONDITION(cond),,); \
176-
if (IS_ENABLED(CONFIG_LOCKDEP)) { \
176+
if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
177177
rcu_read_lock_sched_notrace(); \
178178
rcu_dereference_sched(__tracepoint_##name.funcs);\
179179
rcu_read_unlock_sched_notrace(); \

include/trace/events/tlb.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
{ TLB_LOCAL_SHOOTDOWN, "local shootdown" }, \
1414
{ TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" }
1515

16-
TRACE_EVENT(tlb_flush,
16+
TRACE_EVENT_CONDITION(tlb_flush,
1717

1818
TP_PROTO(int reason, unsigned long pages),
1919
TP_ARGS(reason, pages),
2020

21+
TP_CONDITION(cpu_online(smp_processor_id())),
22+
2123
TP_STRUCT__entry(
2224
__field( int, reason)
2325
__field(unsigned long, pages)

0 commit comments

Comments
 (0)