From 7c72bd783d8bb95b5898584a76898b16aedac73a Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Fri, 9 Oct 2015 09:25:49 -0500 Subject: [PATCH] net/core/cpuhotplug: Drain input_pkt_queue lockless I can constantly see below error report with 4.1 RT-kernel on TI ARM dra7-evm if I'm trying to unplug cpu1: [ 57.737589] CPU1: shutdown [ 57.767537] BUG: spinlock bad magic on CPU#0, sh/137 [ 57.767546] lock: 0xee994730, .magic: 00000000, .owner: /-1, .owner_cpu: 0 [ 57.767552] CPU: 0 PID: 137 Comm: sh Not tainted 4.1.10-rt8-01700-g2c38702-dirty #55 [ 57.767555] Hardware name: Generic DRA74X (Flattened Device Tree) [ 57.767568] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [ 57.767579] [] (show_stack) from [] (dump_stack+0x84/0xa0) [ 57.767593] [] (dump_stack) from [] (spin_dump+0x84/0xac) [ 57.767603] [] (spin_dump) from [] (spin_bug+0x34/0x38) [ 57.767614] [] (spin_bug) from [] (do_raw_spin_lock+0x168/0x1c0) [ 57.767624] [] (do_raw_spin_lock) from [] (_raw_spin_lock+0x4c/0x54) [ 57.767631] [] (_raw_spin_lock) from [] (rt_spin_lock_slowlock+0x5c/0x374) [ 57.767638] [] (rt_spin_lock_slowlock) from [] (rt_spin_lock+0x38/0x70) [ 57.767649] [] (rt_spin_lock) from [] (skb_dequeue+0x28/0x7c) [ 57.767662] [] (skb_dequeue) from [] (dev_cpu_callback+0x1b8/0x240) [ 57.767673] [] (dev_cpu_callback) from [] (notifier_call_chain+0x3c/0xb4) The reason is that skb_dequeue is taking skb->lock, but RT changed the core code to use a raw spinlock. The non-raw lock is not initialized on purpose to catch exactly this kind of problem. Fixes: 91df05da13a6 'net: Use skbufhead with raw lock' Signed-off-by: Thomas Gleixner Cc: stable-rt@vger.kernel.org --- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 536508ef7d5ee1..bcbc5b2b2d3f82 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8449,7 +8449,7 @@ static int dev_cpu_dead(unsigned int oldcpu) netif_rx_ni(skb); input_queue_head_incr(oldsd); } - while ((skb = skb_dequeue(&oldsd->input_pkt_queue))) { + while ((skb = __skb_dequeue(&oldsd->input_pkt_queue))) { netif_rx_ni(skb); input_queue_head_incr(oldsd); }