[BUG] msr-trace.h:42 suspicious rcu_dereference_check() usage!

From: Jiri Olsa
Date: Sun Nov 20 2016 - 19:54:24 EST


hi,
Jan hit following output when msr tracepoints are enabled on amd server:

[ 91.585653] ===============================
[ 91.589840] [ INFO: suspicious RCU usage. ]
[ 91.594025] 4.9.0-rc1+ #1 Not tainted
[ 91.597691] -------------------------------
[ 91.601877] ./arch/x86/include/asm/msr-trace.h:42 suspicious rcu_dereference_check() usage!
[ 91.610222]
[ 91.610222] other info that might help us debug this:
[ 91.610222]
[ 91.618224]
[ 91.618224] RCU used illegally from idle CPU!
[ 91.618224] rcu_scheduler_active = 1, debug_locks = 0
[ 91.629081] RCU used illegally from extended quiescent state!
[ 91.634820] no locks held by swapper/1/0.
[ 91.638832]
[ 91.638832] stack backtrace:
[ 91.643192] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.9.0-rc1+ #1
[ 91.649457] Hardware name: empty empty/S3992, BIOS 'V2.03 ' 05/09/2008
[ 91.656159] ffffc900018fbdf8 ffffffff813ed43c ffff88017ede8000 0000000000000001
[ 91.663637] ffffc900018fbe28 ffffffff810fdcd7 ffff880233f95dd0 00000000c0010055
[ 91.671107] 0000000000000000 0000000000000000 ffffc900018fbe58 ffffffff814297ac
[ 91.678560] Call Trace:
[ 91.681022] [<ffffffff813ed43c>] dump_stack+0x85/0xc9
[ 91.686164] [<ffffffff810fdcd7>] lockdep_rcu_suspicious+0xe7/0x120
[ 91.692429] [<ffffffff814297ac>] do_trace_read_msr+0x14c/0x1b0
[ 91.698349] [<ffffffff8106ddb2>] native_read_msr+0x32/0x40
[ 91.703921] [<ffffffff8103b2be>] amd_e400_idle+0x7e/0x110
[ 91.709407] [<ffffffff8103b78f>] arch_cpu_idle+0xf/0x20
[ 91.714720] [<ffffffff8181cd33>] default_idle_call+0x23/0x40
[ 91.720467] [<ffffffff810f306a>] cpu_startup_entry+0x1da/0x2b0
[ 91.726387] [<ffffffff81058b1f>] start_secondary+0x17f/0x1f0


it got away with attached change.. but this rcu logic
is far beyond me, so it's just wild guess.. ;-)

thanks,
jirka


---
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c
index d1dee753b949..ca15becea3b6 100644
--- a/arch/x86/lib/msr.c
+++ b/arch/x86/lib/msr.c
@@ -115,14 +115,14 @@ int msr_clear_bit(u32 msr, u8 bit)
#ifdef CONFIG_TRACEPOINTS
void do_trace_write_msr(unsigned msr, u64 val, int failed)
{
- trace_write_msr(msr, val, failed);
+ trace_write_msr_rcuidle(msr, val, failed);
}
EXPORT_SYMBOL(do_trace_write_msr);
EXPORT_TRACEPOINT_SYMBOL(write_msr);

void do_trace_read_msr(unsigned msr, u64 val, int failed)
{
- trace_read_msr(msr, val, failed);
+ trace_read_msr_rcuidle(msr, val, failed);
}
EXPORT_SYMBOL(do_trace_read_msr);
EXPORT_TRACEPOINT_SYMBOL(read_msr);