From: Tyrone Lau <tyronelau@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] A deadlock may occur in kni kernel thread while netif_receive_skb is called
Date: Thu, 12 Jun 2014 22:46:14 +0800 [thread overview]
Message-ID: <CAKt-5aSc0qVOLweMonKUXCzFPzh=JE4R0RC4xKCB3hLZ+e4v6g@mail.gmail.com> (raw)
Hi, all. I have found recently the Linux kernel will complain occasionally
a dead lock, while I use the kernel module rte_kni provided in DPDK. After
reviewing the dpdk source code and googling,
I found that the deadlock occurred because netif_receive_skb is invoked in
a non-softirq context. The erroneous source code is listed as below (in
lib/librte_eal/linuxapp/kni/kni_net.c:kni_net_rx_normal):
* /* Transfer received packets to netif */
for (i = 0; i < num; i++) {
kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva;
len = kva->data_len;
data_kva = kva->data - kni->mbuf_va + kni->mbuf_kva;
skb = dev_alloc_skb(len + 2);
if (!skb) {
KNI_ERR("Out of mem, dropping pkts\n");
/* Update statistics */
kni->stats.rx_dropped++;
}
else {
/* Align IP on 16B boundary */
skb_reserve(skb, 2);
memcpy(skb_put(skb, len), data_kva, len);
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY;
/* Call netif interface */
netif_receive_skb(skb);
/* Update statistics */
kni->stats.rx_bytes += len;
kni->stats.rx_packets++;
}
}*
The similar bug is reported and fixed in dpdk extension memnic. See
http://comments.gmane.org/gmane.comp.networking.dpdk.devel/3151
To fix this bug, we should call local_bh_disable/local_bh_enable
around netif_receive_skb to disable and re-enable soft-irq.
Best Regards
next reply other threads:[~2014-06-12 14:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-12 14:46 Tyrone Lau [this message]
2014-06-13 0:21 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKt-5aSc0qVOLweMonKUXCzFPzh=JE4R0RC4xKCB3hLZ+e4v6g@mail.gmail.com' \
--to=tyronelau@gmail.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).