[PATCH net-next v5 0/4] tun/tap: use kfree_skb_reason() to trace dropped skb

Dongli Zhang posted 4 patches 4 years, 3 months ago
There is a newer version of this series
drivers/net/tap.c          | 35 +++++++++++++++++++++++++----------
drivers/net/tun.c          | 38 ++++++++++++++++++++++++++++++--------
include/linux/skbuff.h     | 39 ++++++++++++++++++++++++++++++++++++++-
include/trace/events/skb.h | 10 ++++++++++
net/core/skbuff.c          |  7 ++++---
5 files changed, 107 insertions(+), 22 deletions(-)
[PATCH net-next v5 0/4] tun/tap: use kfree_skb_reason() to trace dropped skb
Posted by Dongli Zhang 4 years, 3 months ago
The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
introduced the kfree_skb_reason() to help track the reason.

The tun and tap are commonly used as virtio-net/vhost-net backend. This is to
use kfree_skb_reason() to trace the dropped skb for those two drivers. 

Changed since v1:
- I have renamed many of the reasons since v1. I make them as generic as
  possible so that they can be re-used by core networking and drivers.

Changed since v2:
- declare drop_reason as type "enum skb_drop_reason"
- handle the drop in skb_list_walk_safe() case for tap driver, and
  kfree_skb_list_reason() is introduced

Changed since v3 (only for PATCH 4/4):
- rename to TAP_FILTER and TAP_TXFILTER
- honor reverse xmas tree style declaration for 'drop_reason' in
  tun_net_xmit()

Changed since v4:
- make kfree_skb_list() static inline
- add 'computation' to SKB_CSUM comment
- change COPY_DATA to UCOPY_FAULT
- add 'metadata' to DEV_HDR comment
- expand comment on DEV_READY
- change SKB_TRIM to NOMEM
- chnage SKB_PULL to HDR_TRUNC


The following reasons are introduced.

- SKB_DROP_REASON_SKB_CSUM
- SKB_DROP_REASON_SKB_GSO_SEG
- SKB_DROP_REASON_SKB_UCOPY_FAULT
- SKB_DROP_REASON_DEV_HDR
- SKB_DROP_REASON_FULL_RING
- SKB_DROP_REASON_DEV_READY
- SKB_DROP_REASON_NOMEM
- SKB_DROP_REASON_HDR_TRUNC
- SKB_DROP_REASON_TAP_FILTER
- SKB_DROP_REASON_TAP_TXFILTER


This is the output for TUN device.

# cat /sys/kernel/debug/tracing/trace_pipe
          <idle>-0       [029] ..s1.   450.727651: kfree_skb: skbaddr=0000000023d235cc protocol=0 location=00000000a6748854 reason: NOT_SPECIFIED
          <idle>-0       [000] b.s3.   451.165671: kfree_skb: skbaddr=000000006b5de7cc protocol=4 location=000000007c2b9eae reason: FULL_RING
          <idle>-0       [000] b.s3.   453.149650: kfree_skb: skbaddr=000000006b5de7cc protocol=4 location=000000007c2b9eae reason: FULL_RING
          <idle>-0       [000] b.s3.   455.133576: kfree_skb: skbaddr=000000006b5de7cc protocol=4 location=000000007c2b9eae reason: FULL_RING
          <idle>-0       [000] b.s3.   457.117566: kfree_skb: skbaddr=000000006b5de7cc protocol=4 location=000000007c2b9eae reason: FULL_RING


This is the output for TAP device.

# cat /sys/kernel/debug/tracing/trace_pipe
          arping-7053    [006] ..s1.  1000.047753: kfree_skb: skbaddr=000000008618a587 protocol=2054 location=00000000743ad4a7 reason: FULL_RING
          <idle>-0       [022] ..s1.  1000.778514: kfree_skb: skbaddr=000000002c1e706c protocol=0 location=00000000a6748854 reason: NOT_SPECIFIED
          arping-7053    [006] ..s1.  1001.047830: kfree_skb: skbaddr=000000008618a587 protocol=2054 location=00000000743ad4a7 reason: FULL_RING
          arping-7053    [006] ..s1.  1002.047918: kfree_skb: skbaddr=000000008618a587 protocol=2054 location=00000000743ad4a7 reason: FULL_RING
          arping-7053    [006] ..s1.  1003.048017: kfree_skb: skbaddr=000000008618a587 protocol=2054 location=00000000743ad4a7 reason: FULL_RING



 drivers/net/tap.c          | 35 +++++++++++++++++++++++++----------
 drivers/net/tun.c          | 38 ++++++++++++++++++++++++++++++--------
 include/linux/skbuff.h     | 39 ++++++++++++++++++++++++++++++++++++++-
 include/trace/events/skb.h | 10 ++++++++++
 net/core/skbuff.c          |  7 ++++---
 5 files changed, 107 insertions(+), 22 deletions(-)


Thank you very much!

Dongli Zhang
Re: [PATCH net-next v5 0/4] tun/tap: use kfree_skb_reason() to trace dropped skb
Posted by David Miller 4 years, 3 months ago
From: Dongli Zhang <dongli.zhang@oracle.com>
Date: Thu,  3 Mar 2022 22:33:03 -0800

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

This patch series does not apply cleanly against net-next, plewase respin.

Thank you.
Re: [PATCH net-next v5 0/4] tun/tap: use kfree_skb_reason() to trace dropped skb
Posted by Dongli Zhang 4 years, 3 months ago
Hi David,

On 3/4/22 4:25 AM, David Miller wrote:
> From: Dongli Zhang <dongli.zhang@oracle.com>
> Date: Thu,  3 Mar 2022 22:33:03 -0800
> 
>> The commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()") has
>> introduced the kfree_skb_reason() to help track the reason.
>>
>> The tun and tap are commonly used as virtio-net/vhost-net backend. This is to
>> use kfree_skb_reason() to trace the dropped skb for those two drivers. 
> 
> This patch series does not apply cleanly against net-next, plewase respin.
> 

Sorry for that. I will rebase to the most recent net-next.

Unfortunately, one patch just merged to net-next has already been in my patchset ...

https://lore.kernel.org/netdev/40f63798-2b85-c31c-9722-ee24d55093a8@oracle.com/

...  so that I will need to remove my PATCH 1/4 and rebase.

Thank you very much!

Dongli Zhang