From: roopa <roopa@cumulusnetworks.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com
Subject: Re: [PATCH net-next v2 1/2] rtnetlink: add new RTM_GETSTATS message to dump link stats
Date: Wed, 13 Apr 2016 23:35:26 -0700 [thread overview]
Message-ID: <570F3A2E.2000707@cumulusnetworks.com> (raw)
In-Reply-To: <20160414.001948.1059678462607051806.davem@davemloft.net>
On 4/13/16, 9:19 PM, David Miller wrote:
> From: Roopa Prabhu <roopa@cumulusnetworks.com>
> Date: Fri, 8 Apr 2016 23:38:11 -0700
>
>> This patch adds a new RTM_GETSTATS message to query link stats via netlink
>> from the kernel. RTM_NEWLINK also dumps stats today, but RTM_NEWLINK
>> returns a lot more than just stats and is expensive in some cases when
>> frequent polling for stats from userspace is a common operation.
> Great work. One thing catches my eye:
>
>> + if (filter_mask & IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK64)) {
>> + attr = nla_reserve(skb, IFLA_STATS_LINK64,
>> + sizeof(struct rtnl_link_stats64));
>> + if (!attr)
>> + return -EMSGSIZE;
>> +
>> + stats = dev_get_stats(dev, &temp);
>> +
>> + copy_rtnl_link_stats64(nla_data(attr), stats);
> This extra copy bothers me, so I tried to figure out what is going
> on here.
>
> dev_get_stats() always returns the rtnl_link_stats64 pointer it was
> given. We should be able to pass, therefore, nla_data(attr), straight
> there to avoid the copy.
nice catch. I picked this up straight from rtnl_fill_stats. agree, also thanks
for the example below.
>
> Bonding even uses dev_get_stats() in this way.
>
> The existing rtnl_fill_stats() can be improved similarly but is of
> course a separate change. In that case, we'd do something like:
>
> struct rtnl_link_stats64 *sp;
>
> attr = nla_reserve(skb, IFLA_STATS64,
> sizeof(struct rtnl_link_stats64));
> if (!attr)
> return -EMSGSIZE;
>
> sp = nla_data(attr);
> dev_get_stats(dev, sp);
>
> attr = nla_reserve(skb, IFLA_STATS,
> sizeof(struct rtnl_link_stats));
> if (!attr)
> return -EMSGSIZE;
>
> copy_rtnl_link_stats(nla_data(attr), sp);
I will submit a separate patch for this with some testing.
Will send a v3 out before end of this week.
Thank you!.
prev parent reply other threads:[~2016-04-14 6:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-09 6:38 [PATCH net-next v2 1/2] rtnetlink: add new RTM_GETSTATS message to dump link stats Roopa Prabhu
2016-04-09 14:30 ` Jamal Hadi Salim
2016-04-09 18:00 ` roopa
2016-04-10 13:48 ` Jamal Hadi Salim
2016-04-10 19:17 ` roopa
2016-04-10 8:16 ` Thomas Graf
2016-04-10 18:28 ` roopa
2016-04-12 3:53 ` roopa
2016-04-12 13:21 ` Thomas Graf
2016-04-13 12:11 ` Jamal Hadi Salim
2016-04-14 6:36 ` roopa
2016-04-14 4:19 ` David Miller
2016-04-14 6:35 ` roopa [this message]
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=570F3A2E.2000707@cumulusnetworks.com \
--to=roopa@cumulusnetworks.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=netdev@vger.kernel.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).