From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Yajun Deng <yajun.deng@linux.dev>, <davem@davemloft.net>,
<kuba@kernel.org>, <pabeni@redhat.com>, <horms@kernel.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net/core: Export dev_core_stats_rx_dropped_inc sets
Date: Tue, 12 Sep 2023 17:57:26 +0200 [thread overview]
Message-ID: <f3e84a37-3218-0d52-e7ed-2d215fed58e3@intel.com> (raw)
In-Reply-To: <CANn89i+W1iAQmOhunLbqpvHu8EUO6uawv6Uvx7qimyBa_PBNCg@mail.gmail.com>
From: Eric Dumazet <edumazet@google.com>
Date: Tue, 12 Sep 2023 06:23:24 +0200
> On Mon, Sep 11, 2023 at 10:20 AM Yajun Deng <yajun.deng@linux.dev> wrote:
>>
>> Although there is a kfree_skb_reason() helper function that can be used
>> to find the reason for dropped packets, but most callers didn't increase
>> one of rx_dropped, tx_dropped, rx_nohandler and rx_otherhost_dropped.
[...]
>> EXPORT_SYMBOL(netdev_stats_to_stats64);
>>
>> -struct net_device_core_stats __percpu *netdev_core_stats_alloc(struct net_device *dev)
>> +static struct net_device_core_stats __percpu *netdev_core_stats_alloc(struct net_device *dev)
>> {
>> struct net_device_core_stats __percpu *p;
>>
>> @@ -10488,7 +10488,33 @@ struct net_device_core_stats __percpu *netdev_core_stats_alloc(struct net_device
>> /* This READ_ONCE() pairs with the cmpxchg() above */
>> return READ_ONCE(dev->core_stats);
>> }
>> -EXPORT_SYMBOL(netdev_core_stats_alloc);
>> +
>> +static inline struct net_device_core_stats __percpu *dev_core_stats(struct net_device *dev)
>
> Please remove this inline attritbute. Consider using __cold instead.
__cold? O_o I thought the author's inlining it as it's a couple
locs/intstructions, while the compilers would most likely keep it
non-inlined as it's referenced 4 times. __cold will for sure keep it
standalone and place it in .text.cold, i.e. far away from the call sites.
I realize dev_core_stats_*() aren't called frequently, but why making
only one small helper cold rather than all of them then?
>
>> +{
>> + /* This READ_ONCE() pairs with the write in netdev_core_stats_alloc() */
>> + struct net_device_core_stats __percpu *p = READ_ONCE(dev->core_stats);
>> +
>> + if (likely(p))
>> + return p;
>> +
>> + return netdev_core_stats_alloc(dev);
>> +}
[...]
Thanks,
Olek
next prev parent reply other threads:[~2023-09-12 15:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 8:20 [PATCH] net/core: Export dev_core_stats_rx_dropped_inc sets Yajun Deng
2023-09-11 16:15 ` Stephen Hemminger
2023-09-12 1:42 ` Yajun Deng
2023-09-12 4:23 ` Eric Dumazet
2023-09-12 15:57 ` Alexander Lobakin [this message]
2023-09-12 16:04 ` Eric Dumazet
2023-09-12 17:15 ` Alexander Lobakin
2023-09-12 17:28 ` Eric Dumazet
2023-09-12 17:43 ` Alexander Lobakin
2023-09-12 18:03 ` Eric Dumazet
2023-09-12 18:05 ` Eric Dumazet
2023-09-13 2:20 ` Yajun Deng
2023-09-12 16:22 ` Alexander Lobakin
[not found] ` <599cdff8-4865-3ade-0439-36e337891ca0@linux.dev>
2023-09-13 9:58 ` Alexander Lobakin
2023-09-14 2:44 ` Yajun Deng
2023-09-14 14:10 ` Alexander Lobakin
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=f3e84a37-3218-0d52-e7ed-2d215fed58e3@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yajun.deng@linux.dev \
/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).