* [PATCH v2] ipv6: fix the use of pcpu_tstats in ip6_tunnel
@ 2014-01-02 5:20 roy.qing.li
2014-01-03 0:37 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: roy.qing.li @ 2014-01-02 5:20 UTC (permalink / raw)
To: netdev; +Cc: stephen, edumazet
From: Li RongQing <roy.qing.li@gmail.com>
when read/write the 64bit data, the correct lock should be hold.
Fixes: 87b6d218f3adb ("tunnel: implement 64 bits statistics")
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
net/ipv6/ip6_tunnel.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 8d7c986..f68bcca 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -102,16 +102,25 @@ struct ip6_tnl_net {
static struct net_device_stats *ip6_get_stats(struct net_device *dev)
{
- struct pcpu_tstats sum = { 0 };
+ struct pcpu_tstats tmp, sum = { 0 };
int i;
for_each_possible_cpu(i) {
+ unsigned int start;
const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
- sum.rx_packets += tstats->rx_packets;
- sum.rx_bytes += tstats->rx_bytes;
- sum.tx_packets += tstats->tx_packets;
- sum.tx_bytes += tstats->tx_bytes;
+ do {
+ start = u64_stats_fetch_begin_bh(&tstats->syncp);
+ tmp.rx_packets = tstats->rx_packets;
+ tmp.rx_bytes = tstats->rx_bytes;
+ tmp.tx_packets = tstats->tx_packets;
+ tmp.tx_bytes = tstats->tx_bytes;
+ } while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
+
+ sum.rx_packets += tmp.rx_packets;
+ sum.rx_bytes += tmp.rx_bytes;
+ sum.tx_packets += tmp.tx_packets;
+ sum.tx_bytes += tmp.tx_bytes;
}
dev->stats.rx_packets = sum.rx_packets;
dev->stats.rx_bytes = sum.rx_bytes;
@@ -823,8 +832,10 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
}
tstats = this_cpu_ptr(t->dev->tstats);
+ u64_stats_update_begin(&tstats->syncp);
tstats->rx_packets++;
tstats->rx_bytes += skb->len;
+ u64_stats_update_end(&tstats->syncp);
netif_rx(skb);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ipv6: fix the use of pcpu_tstats in ip6_tunnel
2014-01-02 5:20 [PATCH v2] ipv6: fix the use of pcpu_tstats in ip6_tunnel roy.qing.li
@ 2014-01-03 0:37 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-01-03 0:37 UTC (permalink / raw)
To: roy.qing.li; +Cc: netdev, stephen, edumazet
From: roy.qing.li@gmail.com
Date: Thu, 2 Jan 2014 13:20:12 +0800
> From: Li RongQing <roy.qing.li@gmail.com>
>
> when read/write the 64bit data, the correct lock should be hold.
>
> Fixes: 87b6d218f3adb ("tunnel: implement 64 bits statistics")
>
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-03 0:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-02 5:20 [PATCH v2] ipv6: fix the use of pcpu_tstats in ip6_tunnel roy.qing.li
2014-01-03 0:37 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.