From: Dongli Zhang <dongli.zhang@oracle.com>
To: David Ahern <dsahern@gmail.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, davem@davemloft.net,
kuba@kernel.org, rostedt@goodmis.org, mingo@redhat.com,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
imagedong@tencent.com, joao.m.martins@oracle.com,
joe.jin@oracle.com, edumazet@google.com
Subject: Re: [PATCH v2 1/3] net: tap: track dropped skb via kfree_skb_reason()
Date: Sat, 19 Feb 2022 21:39:52 -0800 [thread overview]
Message-ID: <172e9385-6c24-6473-7670-57bc33960979@oracle.com> (raw)
In-Reply-To: <a76d0c63-f747-d33c-d782-0b2f696e7de9@gmail.com>
Hi David,
On 2/19/22 2:46 PM, David Ahern wrote:
> On 2/19/22 12:12 PM, Dongli Zhang wrote:
>> The TAP can be used as vhost-net backend. E.g., the tap_handle_frame() is
>> the interface to forward the skb from TAP to vhost-net/virtio-net.
>>
>> However, there are many "goto drop" in the TAP driver. Therefore, the
>> kfree_skb_reason() is involved at each "goto drop" to help userspace
>> ftrace/ebpf to track the reason for the loss of packets.
>>
>> The below reasons are introduced:
>>
>> - SKB_DROP_REASON_SKB_CSUM
>> - SKB_DROP_REASON_SKB_COPY_DATA
>> - SKB_DROP_REASON_SKB_GSO_SEG
>> - SKB_DROP_REASON_DEV_HDR
>> - SKB_DROP_REASON_FULL_RING
>>
>> Cc: Joao Martins <joao.m.martins@oracle.com>
>> Cc: Joe Jin <joe.jin@oracle.com>
>> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
>> ---
>> drivers/net/tap.c | 30 ++++++++++++++++++++++--------
>> include/linux/skbuff.h | 9 +++++++++
>> include/trace/events/skb.h | 5 +++++
>> 3 files changed, 36 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
>> index 8e3a28ba6b28..ab3592506ef8 100644
>> --- a/drivers/net/tap.c
>> +++ b/drivers/net/tap.c
>> @@ -322,6 +322,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
>> struct tap_dev *tap;
>> struct tap_queue *q;
>> netdev_features_t features = TAP_FEATURES;
>> + int drop_reason;
>
> enum skb_drop_reason drop_reason;
According to cscope, so far all 'drop_reason' are declared in type 'int' (e.g.,
ip_rcv_finish_core()).
I will change above to enum.
>
>>
>> tap = tap_dev_get_rcu(dev);
>> if (!tap)
>> @@ -343,12 +344,16 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
>> struct sk_buff *segs = __skb_gso_segment(skb, features, false);
>> struct sk_buff *next;
>>
>> - if (IS_ERR(segs))
>> + if (IS_ERR(segs)) {
>> + drop_reason = SKB_DROP_REASON_SKB_GSO_SEG;
>> goto drop;
>> + }
>>
>> if (!segs) {
>> - if (ptr_ring_produce(&q->ring, skb))
>> + if (ptr_ring_produce(&q->ring, skb)) {
>> + drop_reason = SKB_DROP_REASON_FULL_RING;
>> goto drop;
>> + }
>> goto wake_up;
>> }
>
> you missed the walk of segs and calling ptr_ring_produce.
This call site of kfree_skb() and kfree_skb_list() is unique and there is not
any "goto drop" involved. From developers' view, we will be able to tell if the
'drop' is at here according to the instruction pointers in callstack.
360 consume_skb(skb);
361 skb_list_walk_safe(segs, skb, next) {
362 skb_mark_not_on_list(skb);
363 if (ptr_ring_produce(&q->ring, skb)) {
364 kfree_skb(skb);
365 kfree_skb_list(next);
366 break;
367 }
368 }
I will add the reason to "walk of segs" case as well. About kfree_skb_list(), I
will introduce a kfree_skb_list_reason().
Thank you very much!
Dongli Zhang
next prev parent reply other threads:[~2022-02-20 5:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 19:12 [PATCH v2 0/3] tun/tap: use kfree_skb_reason() to trace dropped skb Dongli Zhang
2022-02-19 19:12 ` [PATCH v2 1/3] net: tap: track dropped skb via kfree_skb_reason() Dongli Zhang
2022-02-19 22:46 ` David Ahern
2022-02-20 5:39 ` Dongli Zhang [this message]
2022-02-19 19:12 ` [PATCH v2 2/3] net: tun: split run_ebpf_filter() and pskb_trim() into different "if statement" Dongli Zhang
2022-02-19 19:12 ` [PATCH v2 3/3] net: tun: track dropped skb via kfree_skb_reason() Dongli Zhang
2022-02-19 22:54 ` David Ahern
2022-02-20 5:40 ` Dongli Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=172e9385-6c24-6473-7670-57bc33960979@oracle.com \
--to=dongli.zhang@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=edumazet@google.com \
--cc=imagedong@tencent.com \
--cc=joao.m.martins@oracle.com \
--cc=joe.jin@oracle.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox