Blob Blame History Raw
commit 2699450dde9af4cc609bdeca2b346a014840f0f0
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Thu Jan 23 13:35:30 2020 -0500

    RHBZ1788662: check rcu_is_watching() before probe entry
    
    Some tracepoints are problematic because they are called from an idle
    context, where RCU/lockdep is not legal to call.  On lockdep kernels,
    RCU warnings and even possibly-related panics have been reported.
    
    Kernel tracepoint handlers protect themselves by wrapping their
    innards in rcu_irq_enter/rcu_irq_exit(), which flips the legality flag
    back on (even during idle), but these functions are not
    module-exported, and it's not clear they'd be sufficient anyway.  So
    we call the module-export'd rcu_is_watching() in
    _stp_runtime_get_context() to reject any attempt to start a probe in
    such an idling-cpu context.  This covers the cpu_idle tracepoint as
    well as others.

diff --git a/runtime/linux/runtime_context.h b/runtime/linux/runtime_context.h
index 48894a6..db38bfc 100644
--- a/runtime/linux/runtime_context.h
+++ b/runtime/linux/runtime_context.h
@@ -73,6 +73,8 @@ static void _stp_runtime_contexts_free(void)
 
 static inline struct context * _stp_runtime_get_context(void)
 {
+        if (! rcu_is_watching()) // rcu operations are rejected in idle-cpu contexts
+                return 0; // in effect: skip probe
 	return rcu_dereference_sched(contexts[smp_processor_id()]);
 }