net: dsa: User per-cpu 64-bit statistics

During testing with a background iperf pushing 1Gbit/sec worth of
traffic and having both ifconfig and ethtool collect statistics, we
could see quite frequent deadlocks. Convert the often accessed DSA slave
network devices statistics to per-cpu 64-bit statistics to remove these
deadlocks and provide fast efficient statistics updates.

Fixes: f613ed665b ("net: dsa: Add support for 64-bit statistics")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Florian Fainelli 2017-08-03 21:33:27 -07:00 committed by David S. Miller
parent eaf6dc0338
commit 5f6b4e14ca
3 changed files with 58 additions and 24 deletions

View file

@ -190,6 +190,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
struct sk_buff *nskb = NULL;
struct pcpu_sw_netstats *s;
struct dsa_slave_priv *p;
if (unlikely(dst == NULL)) {
@ -213,10 +214,11 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
skb->pkt_type = PACKET_HOST;
skb->protocol = eth_type_trans(skb, skb->dev);
u64_stats_update_begin(&p->stats64.syncp);
p->stats64.rx_packets++;
p->stats64.rx_bytes += skb->len;
u64_stats_update_end(&p->stats64.syncp);
s = this_cpu_ptr(p->stats64);
u64_stats_update_begin(&s->syncp);
s->rx_packets++;
s->rx_bytes += skb->len;
u64_stats_update_end(&s->syncp);
netif_receive_skb(skb);