diff options
author | Roopa Prabhu <roopa@cumulusnetworks.com> | 2016-04-15 20:36:25 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-18 12:41:13 -0400 |
commit | 550bce59baf3f3059cd4ae1e268f08f2d2cb1d5c (patch) | |
tree | af92a017007ef4123f16808e5acd00037377eaf6 | |
parent | ccd37cffe39d7d4f1c1efcd42ec829ec16c7db66 (diff) | |
download | linux-stable-550bce59baf3f3059cd4ae1e268f08f2d2cb1d5c.tar.gz linux-stable-550bce59baf3f3059cd4ae1e268f08f2d2cb1d5c.tar.bz2 linux-stable-550bce59baf3f3059cd4ae1e268f08f2d2cb1d5c.zip |
rtnetlink: rtnl_fill_stats: avoid an unnecssary stats copy
This patch passes netlink attr data ptr directly to dev_get_stats
thus elimiating a stats copy.
Suggested-by: David Miller <davem@davemloft.net>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/rtnetlink.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a75f7e94b445..a7a3d345134a 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -808,11 +808,6 @@ static void copy_rtnl_link_stats(struct rtnl_link_stats *a, a->rx_nohandler = b->rx_nohandler; } -static void copy_rtnl_link_stats64(void *v, const struct rtnl_link_stats64 *b) -{ - memcpy(v, b, sizeof(*b)); -} - /* All VF info */ static inline int rtnl_vfinfo_size(const struct net_device *dev, u32 ext_filter_mask) @@ -1054,25 +1049,23 @@ static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) static noinline_for_stack int rtnl_fill_stats(struct sk_buff *skb, struct net_device *dev) { - const struct rtnl_link_stats64 *stats; - struct rtnl_link_stats64 temp; + struct rtnl_link_stats64 *sp; struct nlattr *attr; - stats = dev_get_stats(dev, &temp); - - attr = nla_reserve(skb, IFLA_STATS, - sizeof(struct rtnl_link_stats)); + attr = nla_reserve(skb, IFLA_STATS64, + sizeof(struct rtnl_link_stats64)); if (!attr) return -EMSGSIZE; - copy_rtnl_link_stats(nla_data(attr), stats); + sp = nla_data(attr); + dev_get_stats(dev, sp); - attr = nla_reserve(skb, IFLA_STATS64, - sizeof(struct rtnl_link_stats64)); + attr = nla_reserve(skb, IFLA_STATS, + sizeof(struct rtnl_link_stats)); if (!attr) return -EMSGSIZE; - copy_rtnl_link_stats64(nla_data(attr), stats); + copy_rtnl_link_stats(nla_data(attr), sp); return 0; } |