aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2013-12-05 07:45:08 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-06 15:24:02 -0500
commite6247027e5173c00efb2084d688d06ff835bc3b0 (patch)
tree44c1fc4da5358f778fc82a1056ef9a2a6e7eea0e /include/linux/netdevice.h
parentf96eb74c84ebb09a03031f7f1e51789a928f9de0 (diff)
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>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h53
1 files changed, 44 insertions, 9 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7f0ed423a360..9d55e5188b96 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2368,17 +2368,52 @@ static inline int netif_copy_real_num_queues(struct net_device *to_dev,
2368#define DEFAULT_MAX_NUM_RSS_QUEUES (8) 2368#define DEFAULT_MAX_NUM_RSS_QUEUES (8)
2369int netif_get_num_default_rss_queues(void); 2369int netif_get_num_default_rss_queues(void);
2370 2370
2371/* Use this variant when it is known for sure that it 2371enum skb_free_reason {
2372 * is executing from hardware interrupt context or with hardware interrupts 2372 SKB_REASON_CONSUMED,
2373 * disabled. 2373 SKB_REASON_DROPPED,
2374 */ 2374};
2375void dev_kfree_skb_irq(struct sk_buff *skb); 2375
2376void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason);
2377void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason);
2376 2378
2377/* Use this variant in places where it could be invoked 2379/*
2378 * from either hardware interrupt or other context, with hardware interrupts 2380 * It is not allowed to call kfree_skb() or consume_skb() from hardware
2379 * either disabled or enabled. 2381 * interrupt context or with hardware interrupts being disabled.
2382 * (in_irq() || irqs_disabled())
2383 *
2384 * We provide four helpers that can be used in following contexts :
2385 *
2386 * dev_kfree_skb_irq(skb) when caller drops a packet from irq context,
2387 * replacing kfree_skb(skb)
2388 *
2389 * dev_consume_skb_irq(skb) when caller consumes a packet from irq context.
2390 * Typically used in place of consume_skb(skb) in TX completion path
2391 *
2392 * dev_kfree_skb_any(skb) when caller doesn't know its current irq context,
2393 * replacing kfree_skb(skb)
2394 *
2395 * dev_consume_skb_any(skb) when caller doesn't know its current irq context,
2396 * and consumed a packet. Used in place of consume_skb(skb)
2380 */ 2397 */
2381void dev_kfree_skb_any(struct sk_buff *skb); 2398static inline void dev_kfree_skb_irq(struct sk_buff *skb)
2399{
2400 __dev_kfree_skb_irq(skb, SKB_REASON_DROPPED);
2401}
2402
2403static inline void dev_consume_skb_irq(struct sk_buff *skb)
2404{
2405 __dev_kfree_skb_irq(skb, SKB_REASON_CONSUMED);
2406}
2407
2408static inline void dev_kfree_skb_any(struct sk_buff *skb)
2409{
2410 __dev_kfree_skb_any(skb, SKB_REASON_DROPPED);
2411}
2412
2413static inline void dev_consume_skb_any(struct sk_buff *skb)
2414{
2415 __dev_kfree_skb_any(skb, SKB_REASON_CONSUMED);
2416}
2382 2417
2383int netif_rx(struct sk_buff *skb); 2418int netif_rx(struct sk_buff *skb);
2384int netif_rx_ni(struct sk_buff *skb); 2419int netif_rx_ni(struct sk_buff *skb);