netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yajun.deng@linux.dev
To: "Jakub Kicinski" <kuba@kernel.org>
Cc: davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: dev: introduce netdev_drop_inc()
Date: Wed, 09 Feb 2022 07:27:44 +0000	[thread overview]
Message-ID: <e95e51e3cdf771650ae64d5295e1178a@linux.dev> (raw)
In-Reply-To: <20220208195306.05a1760f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

February 9, 2022 11:53 AM, "Jakub Kicinski" <kuba@kernel.org> wrote:

> On Wed, 09 Feb 2022 02:20:07 +0000 yajun.deng@linux.dev wrote:
> 
>> February 9, 2022 8:27 AM, "Jakub Kicinski" <kuba@kernel.org> wrote:
>> 
>> On Tue, 8 Feb 2022 14:43:18 +0800 Yajun Deng wrote:
>> 
>> We will use 'sudo perf record -g -a -e skb:kfree_skb' command to trace
>> the dropped packets when dropped increase in the output of ifconfig.
>> But there are two cases, one is only called kfree_skb(), another is
>> increasing the dropped and called kfree_skb(). The latter is what
>> we need. So we need to separate these two cases.
>> 
>> From the other side, the dropped packet came from the core network and
>> the driver, we also need to separate these two cases.
>> 
>> Add netdev_drop_inc() and add a tracepoint for the core network dropped
>> packets. use 'sudo perf record -g -a -e net:netdev_drop' and 'sudo perf
>> script' will recored the dropped packets by the core network.
>> 
>> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
>> 
>> Have you seen the work that's being done around kfree_skb_reason()?
>> 
>> Yes, I saw it. The focus of kfree_skb_reason() is trace kfree_skb() and the reason,
>> but the focus of this patch only traces this case of the dropped packet.
>> 
>> I don't want to trace all kfree_skb(), but I just want to trace the dropped packet.
>> 
>> This command 'sudo perf record -g -a -e skb:kfree_skb' would trace all kfree_skb(),
>> kfree_skb() would drowned out the case of dropped packets when the samples were too large.
> 
> IIRC perf support filters, I think with -f? We can't add a tracepoint
> for every combination of attributes.

Yes, we can use a command like this: " sudo perf record -g -a -e skb:kfree_skb --filter 'protocol == 0x0800' ",
However, only the filter is defined in kfree_skb tracepoint are available.

The purpose of this patch is record {rx_dropped, tx_dropped, rx_nohandler} in struct net_device, to distinguish 
with struct net_device_stats. 

We don't have any tracepoint records {rx_dropped, tx_dropped, rx_nohandler} in struct net_device now. 
Can we add {rx_dropped, tx_dropped, rx_nohandler} in kfree_skb tracepoint?  like this:

        TP_STRUCT__entry(
                __field(void *,         skbaddr)
                __field(void *,         location)
                __field(unsigned short, protocol)
                __field(enum skb_drop_reason,   reason)
                __field(unsigned long,  rx_dropped)
                __field(unsigned long,  tx_dropped)
                __field(unsigned long,  rx_nohandler)

        ),

        TP_fast_assign(
                __entry->skbaddr = skb;
                __entry->location = location;
                __entry->protocol = ntohs(skb->protocol);
                __entry->reason = reason;
                __entry->rx_dropped   = (unsigned long)atomic_long_read(&skb->dev->rx_dropped);
                __entry->tx_dropped   = (unsigned long)atomic_long_read(&skb->dev->tx_dropped);
                __entry->rx_nohandler = (unsigned long)atomic_long_read(&skb->dev->rx_nohandler);
        ),

If so, we can record this but not add a tracepoint.

  reply	other threads:[~2022-02-09  7:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  6:43 [PATCH net-next] net: dev: introduce netdev_drop_inc() Yajun Deng
2022-02-09  0:27 ` Jakub Kicinski
2022-02-09  2:20   ` yajun.deng
2022-02-09  3:53     ` Jakub Kicinski
2022-02-09  7:27       ` yajun.deng [this message]
2022-02-09 15:31         ` Jakub Kicinski

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=e95e51e3cdf771650ae64d5295e1178a@linux.dev \
    --to=yajun.deng@linux.dev \
    --cc=davem@davemloft.net \
    --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;
as well as URLs for NNTP newsgroup(s).