Skip to contentSkip to conversation

kni: use netif_rx instead of netif_receive_skb in which ocurr deallock on userpace contex

PATCH In review Yao-Po Wang 3 participants 4 messages Jul 11, 2014 – Jul 19, 2014 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kni: use netif_rx instead of netif_receive_skb in which ocurr deallock on userpace contex

Per netif_receive_skb function description, it may only be called from interrupt contex, but KNI is run on kthread that like as user-space contex. It may occur deallock, if netif_receive_skb called from kthread, so it should be repleaced by netif_rx or adding local_bh_disable/enable around netif_receive_skb.

---
 lib/librte_eal/linuxapp/kni/kni_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/kni/kni_net.c +1 -1
index d3c0190..28cc5ab 100644
@@ -179,7 +179,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 			/* Call netif interface */
-			netif_receive_skb(skb);
+			netif_rx(skb);
 
 			/* Update statistics */
 			kni->stats.rx_bytes += len;
Signature · 1 line
2.0.0
#2 lore raw
In reply to a message not in the archive

Hi,

2014-07-11 23:37, Yao-Po Wang:

lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 182

Quoted 13 lines

Per netif_receive_skb function description, it may only be called from interrupt contex, but KNI is run on kthread that like as user-space contex. It may occur deallock, if netif_receive_skb called from kthread, so it should be repleaced by netif_rx or adding local_bh_disable/enable around netif_receive_skb.

lib/librte_eal/linuxapp/kni/kni_net.c +1 -1
 			/* Call netif interface */
-			netif_receive_skb(skb);
+			netif_rx(skb);

Is there someone confident to approve this change?

Signature · 1 line
Thomas
#3 lore raw
Quoted 11 lines · Thomas Monjalon

Hi,

2014-07-11 23:37, Yao-Po Wang:

Quoted 7 lines

Per netif_receive_skb function description, it may only be called from interrupt contex, but KNI is run on kthread that like as user-space contex. It may occur deallock, if netif_receive_skb called from kthread, so it should be repleaced by netif_rx or adding local_bh_disable/enable around netif_receive_skb.

Quoted 7 lines

lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 182

Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_net.c +1 -1
                      /* Call netif interface */
-                     netif_receive_skb(skb);
+                     netif_rx(skb);

Is there someone confident to approve this change?

Yao-Po is correct.

Please see this comment In Linux source code .
http://lxr.free-electrons.com/source/net/core/dev.c#L3715

Context:
All todays network drivers use(ixgbe is no exception) NAPI which is a soft irq context of the receive flow .
This is the context in which netif_receive_skb should be called in. KNI is not soft IRQ context so the generic netif_rx is the right function.

Quoted 3 lines

--
Thomas

#5 lore raw
In reply to a message not in the archive

2014-07-17 15:24, Alex Markuze:

Quoted 23 lines

On Thu, Jul 17, 2014 at 3:02 PM, Thomas Monjalon

Quoted 9 lines

2014-07-11 23:37, Yao-Po Wang:

Quoted 7 lines

Per netif_receive_skb function description, it may only be called from interrupt contex, but KNI is run on kthread that like as user-space contex. It may occur deallock, if netif_receive_skb called from kthread, so it should be repleaced by netif_rx or adding local_bh_disable/enable around netif_receive_skb.

Quoted 7 lines

lib/librte_eal/linuxapp/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 182

Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_net.c +1 -1
                      /* Call netif interface */
-                     netif_receive_skb(skb);
+                     netif_rx(skb);

Is there someone confident to approve this change?

Yao-Po is correct.

Please see this comment In Linux source code .
http://lxr.free-electrons.com/source/net/core/dev.c#L3715

Quoted 6 lines

Context:
All todays network drivers use(ixgbe is no exception) NAPI which is a soft irq context of the receive flow .
This is the context in which netif_receive_skb should be called in. KNI is not soft IRQ context so the generic netif_rx is the right function.

Thanks for confirmation.
Assuming Acked-by: Alex Markuze <[email protected]>

Applied for version 1.7.1

Thanks

Signature · 1 line
Thomas