From: Eric Dumazet <eric.dumazet@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
Thomas Graf <tgraf@redhat.com>, Neil Horman <nhorman@redhat.com>,
netdev@vger.kernel.org
Subject: Re: tun: Use netif_receive_skb instead of netif_rx
Date: Wed, 19 May 2010 10:09:42 +0200 [thread overview]
Message-ID: <1274256582.2766.5.camel@edumazet-laptop> (raw)
In-Reply-To: <20100519075721.GA23926@gondor.apana.org.au>
Le mercredi 19 mai 2010 à 17:57 +1000, Herbert Xu a écrit :
> Hi:
>
> tun: Use netif_receive_skb instead of netif_rx
>
> First a bit of history as I recall, Dave can correct me where
> he recalls differently :)
>
> 1) There was netif_rx and everyone had to use that.
> 2) Everyone had to use that, including drivers/net/tun.c.
> 3) NAPI brings us netif_receive_skb.
> 4) About the same time people noticed that tun.c can cause wild
> fluctuations in latency because of its use of netif_rx with IRQs
> enabled.
> 5) netif_rx_ni was added to address this.
>
6) netif_rx() pro is that packet processing is done while stack usage is
guaranteed to be low (from process_backlog, using a special softirq
stack, instead of current stack)
After your patch, tun will use more stack. Is it safe on all contexts ?
Another concern I have is about RPS.
netif_receive_skb() must be called from process_backlog() context, or
there is no guarantee the IPI will be sent if this skb is enqueued for
another cpu.
> However, netif_rx_ni
> was really a bit of a roundabout way of
> injecting a packet if you think about it. What ends up happening
> is that we always queue the packet into the backlog, and then
> immediately process it. Which is what would happen if we simply
> called netif_receive_skb directly.
>
> So this patch just does the obvious thing and makes tun.c call
> netif_receive_skb, albeit through the netif_receive_skb_ni wrapper
> which does the necessary things for calling it in process context.
>
> Now apart from potential performance gains from eliminating
> unnecessary steps in the process, this has the benefit of keeping
> the process context for the packet processing. This is needed
> by cgroups to shape network traffic based on the original process.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 4326520..0eed49f 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -667,7 +667,7 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
> skb_shinfo(skb)->gso_segs = 0;
> }
>
> - netif_rx_ni(skb);
> + netif_receive_skb_ni(skb);
>
> tun->dev->stats.rx_packets++;
> tun->dev->stats.rx_bytes += len;
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index fa8b476..34bb405 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1562,6 +1562,18 @@ extern int netif_rx(struct sk_buff *skb);
> extern int netif_rx_ni(struct sk_buff *skb);
> #define HAVE_NETIF_RECEIVE_SKB 1
> extern int netif_receive_skb(struct sk_buff *skb);
> +
> +static inline int netif_receive_skb_ni(struct sk_buff *skb)
> +{
> + int err;
> +
> + local_bh_disable();
> + err = netif_receive_skb(skb);
> + local_bh_enable();
> +
> + return err;
> +}
> +
> extern gro_result_t dev_gro_receive(struct napi_struct *napi,
> struct sk_buff *skb);
> extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb);
>
> Cheers,
next prev parent reply other threads:[~2010-05-19 8:09 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 7:57 tun: Use netif_receive_skb instead of netif_rx Herbert Xu
2010-05-19 8:09 ` Eric Dumazet [this message]
2010-05-19 8:18 ` Eric Dumazet
2010-05-19 8:21 ` Herbert Xu
2010-05-19 12:05 ` Neil Horman
2010-05-19 12:55 ` Neil Horman
2010-05-19 18:00 ` Neil Horman
2010-05-19 20:24 ` Neil Horman
2010-05-19 20:49 ` Thomas Graf
2010-05-19 21:00 ` Brian Bloniarz
2010-05-20 2:55 ` David Miller
2010-05-20 2:57 ` Herbert Xu
2010-05-20 3:05 ` David Miller
2010-05-20 3:34 ` Herbert Xu
2010-05-20 3:42 ` Herbert Xu
2010-05-20 3:46 ` David Miller
2010-05-20 4:54 ` Eric Dumazet
2010-05-20 5:01 ` Herbert Xu
2010-05-20 5:15 ` Eric Dumazet
2010-05-20 5:20 ` Herbert Xu
2010-05-20 5:36 ` Eric Dumazet
2010-05-20 5:46 ` Herbert Xu
2010-05-20 6:03 ` Eric Dumazet
2010-05-20 6:11 ` Herbert Xu
2010-05-20 6:19 ` Herbert Xu
2010-05-20 6:52 ` Herbert Xu
2010-05-20 8:10 ` Thomas Graf
2010-05-20 9:40 ` Thomas Graf
2010-05-24 6:44 ` David Miller
2010-05-20 17:29 ` Neil Horman
2010-05-20 23:16 ` Herbert Xu
2010-05-21 0:39 ` Neil Horman
2010-05-21 1:02 ` Herbert Xu
2010-05-21 1:16 ` Herbert Xu
2010-05-24 6:44 ` David Miller
2010-05-21 5:49 ` David Miller
2010-05-21 10:51 ` Neil Horman
2010-05-21 11:08 ` Herbert Xu
2010-05-21 12:59 ` Neil Horman
2010-05-21 16:40 ` Neil Horman
2010-05-22 1:49 ` cls_cgroup: Store classid in struct sock Herbert Xu
2010-05-22 12:26 ` Neil Horman
2010-05-24 5:42 ` Herbert Xu
2010-05-24 6:44 ` David Miller
2010-05-24 6:55 ` David Miller
2010-05-24 7:07 ` Herbert Xu
2010-05-24 7:14 ` David Miller
2010-05-24 11:09 ` Neil Horman
2010-05-24 11:24 ` Herbert Xu
2010-05-19 14:10 ` tun: Use netif_receive_skb instead of netif_rx Eric Dumazet
2010-05-19 14:31 ` Neil Horman
2010-05-19 8:20 ` Herbert Xu
2010-05-19 8:27 ` Eric Dumazet
2010-05-19 8:44 ` Herbert Xu
2010-05-19 20:14 ` David Miller
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=1274256582.2766.5.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=tgraf@redhat.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