lkml.org 
[lkml]   [2013]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[for-next][PATCH 15/18] ftrace/lockdep: Have the RCU lockdep splat show what function triggered
    From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

    When the RCU lockdep splat hits because of the unsafe RCU checker,
    the backtrace does not always show the culprit. But the culprit was
    passed to the unsafe RCU checker.

    Save the ip of the function being traced in a per_cpu variable, and
    when the RCU lockdep detects a problem, it can also print out what
    function was being traced if it was caused by the unsafe RCU checker.

    Cc: Peter Zijlstra <peterz@infradead.org>
    Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
    ---
    include/linux/ftrace.h | 6 ++++++
    kernel/lockdep.c | 2 ++
    kernel/trace/trace_functions.c | 14 +++++++++++++-
    3 files changed, 21 insertions(+), 1 deletion(-)

    diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
    index 4752764..3dbb946 100644
    --- a/include/linux/ftrace.h
    +++ b/include/linux/ftrace.h
    @@ -885,4 +885,10 @@ unsigned long arch_syscall_addr(int nr);

    #endif /* CONFIG_FTRACE_SYSCALLS */

    +#ifdef CONFIG_FTRACE_UNSAFE_RCU_CHECKER
    +extern void print_ftrace_rcu_func(int cpu);
    +#else
    +static inline void print_ftrace_rcu_func(int cpu) { }
    +#endif
    +
    #endif /* _LINUX_FTRACE_H */
    diff --git a/kernel/lockdep.c b/kernel/lockdep.c
    index e16c45b..74272ed 100644
    --- a/kernel/lockdep.c
    +++ b/kernel/lockdep.c
    @@ -4229,6 +4229,8 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
    : "",
    rcu_scheduler_active, debug_locks);

    + print_ftrace_rcu_func(raw_smp_processor_id());
    +
    /*
    * If a CPU is in the RCU-free window in idle (ie: in the section
    * between rcu_idle_enter() and rcu_idle_exit(), then RCU
    diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
    index 9e6902a..1dec979 100644
    --- a/kernel/trace/trace_functions.c
    +++ b/kernel/trace/trace_functions.c
    @@ -562,7 +562,6 @@ static inline int init_func_cmd_traceon(void)
    #ifdef CONFIG_FTRACE_UNSAFE_RCU_CHECKER

    static DEFINE_PER_CPU(int, ftrace_rcu_running);
    -
    static atomic_t ftrace_unsafe_rcu_disabled;

    void ftrace_unsafe_rcu_checker_disable(void)
    @@ -579,6 +578,17 @@ void ftrace_unsafe_rcu_checker_enable(void)
    smp_mb__after_atomic_dec();
    }

    +static DEFINE_PER_CPU(unsigned long, ftrace_rcu_func);
    +
    +void print_ftrace_rcu_func(int cpu)
    +{
    + unsigned long ip = per_cpu(ftrace_rcu_func, cpu);
    +
    + if (ip)
    + printk("ftrace_rcu_func: %pS\n",
    + (void *)per_cpu(ftrace_rcu_func, cpu));
    +}
    +
    static void
    ftrace_unsafe_callback(unsigned long ip, unsigned long parent_ip,
    struct ftrace_ops *op, struct pt_regs *pt_regs)
    @@ -599,10 +609,12 @@ ftrace_unsafe_callback(unsigned long ip, unsigned long parent_ip,
    goto out;

    this_cpu_write(ftrace_rcu_running, 1);
    + this_cpu_write(ftrace_rcu_func, ip);

    /* Should trigger a RCU splat if called from unsafe RCU function */
    rcu_read_lock();
    rcu_read_unlock();
    + this_cpu_write(ftrace_rcu_func, 0);

    this_cpu_write(ftrace_rcu_running, 0);
    out:
    --
    1.7.10.4



    \
     
     \ /
      Last update: 2013-09-04 23:21    [W:4.111 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site