backports: backport dev_consume_skb_any()

dev_consume_skb_any() was added by Eric via commit e6247027e
added as of v3.14 to help do analysis on the different reasons
why an skbs are free'd in particular to let us know how many get
dropped or consumed. The new dev_consume_skb_any() spawned the
inception of an optimization for dev_kfree_skb_irq() which was
implemented through __dev_kfree_skb_irq() which dev_kfree_skb_irq()
now uses. We could have taken advantage of both if kernels had
exported raise_softirq_irqoff() but they don't and as such we
can't reimplement that on backports as it stands right now.

If we'd be building backports in-kernel we could just take the
new implementation of __dev_kfree_skb_irq() as raise_softirq_irqoff()
would be available and we could reap the benefits of the change.
That implemention can be seen as a reference - for now - here:

http://drvbp1.linux-foundation.org/~mcgrof/patches/2014/04/11/pend-2014-04-07.patch

For older kernels for now we just use the singular old version of
dev_kfree_skb_irq() and dev_kfree_skb_any().

mcgrof@ergon ~/linux (git::master)$ git describe --contains e6247027e
v3.14-rc1~94^2~585

commit e6247027e5173c00efb2084d688d06ff835bc3b0
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Dec 5 04:45:08 2013 -0800

    net: introduce dev_consume_skb_any()

    Some network drivers use dev_kfree_skb_any() and dev_kfree_skb_irq()
    helpers to free skbs, both for dropped packets and TX completed ones.

    We need to separate the two causes to get better diagnostics
    given by dropwatch or "perf record -e skb:kfree_skb"

    This patch provides two new helpers, dev_consume_skb_any() and
    dev_consume_skb_irq() to be used for consumed skbs.

    __dev_kfree_skb_irq() is slightly optimized to remove one
    atomic_dec_and_test() in fast path, and use this_cpu_{r|w} accessors.

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Eric Dumazet <edumazet@google.com>
Cc: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
1 file changed