]> git.karo-electronics.de Git - karo-tx-linux.git/commit
net: bulk free infrastructure for NAPI context, use napi_consume_skb
authorJesper Dangaard Brouer <brouer@redhat.com>
Mon, 8 Feb 2016 12:14:59 +0000 (13:14 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Feb 2016 16:59:09 +0000 (11:59 -0500)
commit795bb1c00dd338aa0d12f9a7f1f4776fb3160416
treeab5da980a221b054236b2800d3c4d80358879d86
parent18ac5590e9e37a423c4d26a83b657fcf2b832d5a
net: bulk free infrastructure for NAPI context, use napi_consume_skb

Discovered that network stack were hitting the kmem_cache/SLUB
slowpath when freeing SKBs.  Doing bulk free with kmem_cache_free_bulk
can speedup this slowpath.

NAPI context is a bit special, lets take advantage of that for bulk
free'ing SKBs.

In NAPI context we are running in softirq, which gives us certain
protection.  A softirq can run on several CPUs at once.  BUT the
important part is a softirq will never preempt another softirq running
on the same CPU.  This gives us the opportunity to access per-cpu
variables in softirq context.

Extend napi_alloc_cache (before only contained page_frag_cache) to be
a struct with a small array based stack for holding SKBs.  Introduce a
SKB defer and flush API for accessing this.

Introduce napi_consume_skb() as replacement for e.g. dev_consume_skb_any()
when running in NAPI context.  A small trick to handle/detect if we
are called from netpoll is to see if budget is 0.  In that case, we
need to invoke dev_consume_skb_irq().

Joint work with Alexander Duyck.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/dev.c
net/core/skbuff.c