[dpdk-dev] [memnic PATCH] linux: fix to disable softirq before netif_receive_skb()

Hiroshi Shimamoto h-shimamoto at ct.jp.nec.com
Fri Jun 6 09:54:47 CEST 2014


From: Hiroshi Shimamoto <h-shimamoto at ct.jp.nec.com>

Calling netif_receive_skb() from memnic thread may cause deadlock, if
softirq is not disabled.

The netif_receive_skb() should be called in softirq context, but memnic
thread is not softirq context. That may conflict softirq work like a
timer handler in kernel network stack.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto at ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma at ce.jp.nec.com>
---
 linux/memnic_net.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/linux/memnic_net.c b/linux/memnic_net.c
index fadece6..a1b433a 100644
--- a/linux/memnic_net.c
+++ b/linux/memnic_net.c
@@ -133,8 +133,14 @@ static int memnic_thread(void *param)
 			continue;
 		}
 
+		local_bh_disable();
+		/*
+		 * Disable softirq here to avoid race between timers and
+		 * netif_receive_skb
+		 */
 		for (i = 0; i < n; i++)
 			netif_receive_skb(skbs[i]);
+		local_bh_enable();
 
 		cnt = 0;
 	}
-- 
1.8.4



More information about the dev mailing list