[PATCH 0/2] tun/tap: use kfree_skb_reason() to trace dropped skb

From: Dongli Zhang
Date: Mon Feb 07 2022 - 22:56:34 EST


The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
introduced the kfree_skb_reason() to help track the reason. This is to
use kfree_skb_reason() to trace the dropped skb for those two drivers. The
tun and tap are commonly used as virtio-net/vhost-net backend.

This is the 'stacktrace' example for tap when the skb is dropped because
the ptr ring between tap and vhost-net is full.

kworker/13:0-9759 [013] ..s1. 1439.053393: kfree_skb: skbaddr=000000004109db76 protocol=2054 location=00000000db8dd81c reason: PTR_FULL
kworker/13:0-9759 [013] ..s2. 1439.053431: <stack trace>
=> trace_event_raw_event_kfree_skb
=> kfree_skb_reason.part.0
=> tap_handle_frame
=> __netif_receive_skb_core
=> __netif_receive_skb_one_core
=> process_backlog
=> __napi_poll
=> net_rx_action
=> __do_softirq
=> do_softirq.part.0
=> netif_rx_ni
=> macvlan_broadcast
=> macvlan_process_broadcast
=> process_one_work
=> worker_thread
=> kthread
=> ret_from_fork


This is the 'stacktrace' example for tun when the skb is dropped because
the ptr ring between run and vhost-net is full.

<idle>-0 [000] b.s2. 499.675592: kfree_skb: skbaddr=00000000ff79867d protocol=2054 location=00000000635128db reason: PTR_FULL
<idle>-0 [000] b.s3. 499.675612: <stack trace>
=> trace_event_raw_event_kfree_skb
=> kfree_skb_reason.part.0
=> tun_net_xmit
=> dev_hard_start_xmit
=> sch_direct_xmit
=> __dev_queue_xmit
=> br_dev_queue_push_xmit
=> br_handle_frame_finish
=> br_handle_frame
=> __netif_receive_skb_core
=> __netif_receive_skb_list_core
=> netif_receive_skb_list_internal
=> napi_complete_done
=> ixgbe_poll
=> __napi_poll
=> net_rx_action
=> __do_softirq
=> __irq_exit_rcu
=> common_interrupt
=> asm_common_interrupt
=> cpuidle_enter_state
=> cpuidle_enter
=> do_idle
=> cpu_startup_entry
=> start_kernel
=> secondary_startup_64_no_verify



drivers/net/tap.c | 30 ++++++++++++++++++++++--------
drivers/net/tun.c | 33 +++++++++++++++++++++++++--------
include/linux/skbuff.h | 11 +++++++++++
include/trace/events/skb.h | 11 +++++++++++
4 files changed, 69 insertions(+), 16 deletions(-)


Thank you very much!

Dongli Zhang