DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Tyrone Lau <tyronelau@gmail.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] A deadlock may occur in kni kernel thread while netif_receive_skb is called
Date: Thu, 12 Jun 2014 17:21:15 -0700	[thread overview]
Message-ID: <20140612172115.5dc60812@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <CAKt-5aSc0qVOLweMonKUXCzFPzh=JE4R0RC4xKCB3hLZ+e4v6g@mail.gmail.com>

On Thu, 12 Jun 2014 22:46:14 +0800
Tyrone Lau <tyronelau@gmail.com> wrote:

> 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

Probably better to call netif_rx instead, because that will
handle the case of overrun.

Other comments, this code should be using per-cpu stats.
it should use netdev_alloc_skb_ip_align rather than doing align itself.

Even better yet would be bursting packets into the receive handler.

      reply	other threads:[~2014-06-13  0:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12 14:46 Tyrone Lau
2014-06-13  0:21 ` Stephen Hemminger [this message]

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=20140612172115.5dc60812@nehalam.linuxnetplumber.net \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=tyronelau@gmail.com \
    /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).