aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2013-10-07 18:51:58 -0400
committerIngo Molnar <mingo@kernel.org>2013-11-06 06:40:25 -0500
commit827da44c61419f29ae3be198c342e2147f1a10cb (patch)
tree54cff222bd9ec230df4c92908d41efba7cc9c928 /net
parent32cf7c3c94623514eb882addae307212c1507239 (diff)
net: Explicitly initialize u64_stats_sync structures for lockdep
In order to enable lockdep on seqcount/seqlock structures, we must explicitly initialize any locks. The u64_stats_sync structure, uses a seqcount, and thus we need to introduce a u64_stats_init() function and use it to initialize the structure. This unfortunately adds a lot of fairly trivial initialization code to a number of drivers. But the benefit of ensuring correctness makes this worth while. Because these changes are required for lockdep to be enabled, and the changes are quite trivial, I've not yet split this patch out into 30-some separate patches, as I figured it would be better to get the various maintainers thoughts on how to best merge this change along with the seqcount lockdep enablement. Feedback would be appreciated! Signed-off-by: John Stultz <john.stultz@linaro.org> Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org> Cc: James Morris <jmorris@namei.org> Cc: Jesse Gross <jesse@nicira.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Mirko Lindner <mlindner@marvell.com> Cc: Patrick McHardy <kaber@trash.net> Cc: Roger Luethi <rl@hellgate.ch> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Simon Horman <horms@verge.net.au> Cc: Stephen Hemminger <stephen@networkplumber.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Wensong Zhang <wensong@linux-vs.org> Cc: netdev@vger.kernel.org Link: http://lkml.kernel.org/r/1381186321-4906-2-git-send-email-john.stultz@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/8021q/vlan_dev.c9
-rw-r--r--net/bridge/br_device.c7
-rw-r--r--net/ipv4/af_inet.c14
-rw-r--r--net/ipv4/ip_tunnel.c8
-rw-r--r--net/ipv6/addrconf.c14
-rw-r--r--net/ipv6/af_inet6.c14
-rw-r--r--net/ipv6/ip6_gre.c15
-rw-r--r--net/ipv6/ip6_tunnel.c7
-rw-r--r--net/ipv6/sit.c15
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c25
-rw-r--r--net/openvswitch/datapath.c6
-rw-r--r--net/openvswitch/vport.c8
12 files changed, 137 insertions, 5 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 09bf1c38805b..4deff3ed1da1 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -558,7 +558,7 @@ static const struct net_device_ops vlan_netdev_ops;
558static int vlan_dev_init(struct net_device *dev) 558static int vlan_dev_init(struct net_device *dev)
559{ 559{
560 struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; 560 struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
561 int subclass = 0; 561 int subclass = 0, i;
562 562
563 netif_carrier_off(dev); 563 netif_carrier_off(dev);
564 564
@@ -612,6 +612,13 @@ static int vlan_dev_init(struct net_device *dev)
612 if (!vlan_dev_priv(dev)->vlan_pcpu_stats) 612 if (!vlan_dev_priv(dev)->vlan_pcpu_stats)
613 return -ENOMEM; 613 return -ENOMEM;
614 614
615 for_each_possible_cpu(i) {
616 struct vlan_pcpu_stats *vlan_stat;
617 vlan_stat = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
618 u64_stats_init(&vlan_stat->syncp);
619 }
620
621
615 return 0; 622 return 0;
616} 623}
617 624
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index ca04163635da..7893d641775b 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -88,11 +88,18 @@ out:
88static int br_dev_init(struct net_device *dev) 88static int br_dev_init(struct net_device *dev)
89{ 89{
90 struct net_bridge *br = netdev_priv(dev); 90 struct net_bridge *br = netdev_priv(dev);
91 int i;
91 92
92 br->stats = alloc_percpu(struct br_cpu_netstats); 93 br->stats = alloc_percpu(struct br_cpu_netstats);
93 if (!br->stats) 94 if (!br->stats)
94 return -ENOMEM; 95 return -ENOMEM;
95 96
97 for_each_possible_cpu(i) {
98 struct br_cpu_netstats *br_dev_stats;
99 br_dev_stats = per_cpu_ptr(br->stats, i);
100 u64_stats_init(&br_dev_stats->syncp);
101 }
102
96 return 0; 103 return 0;
97} 104}
98 105
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index cfeb85cff4f0..5f4617e377b8 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1518,6 +1518,7 @@ int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align)
1518 ptr[0] = __alloc_percpu(mibsize, align); 1518 ptr[0] = __alloc_percpu(mibsize, align);
1519 if (!ptr[0]) 1519 if (!ptr[0])
1520 return -ENOMEM; 1520 return -ENOMEM;
1521
1521#if SNMP_ARRAY_SZ == 2 1522#if SNMP_ARRAY_SZ == 2
1522 ptr[1] = __alloc_percpu(mibsize, align); 1523 ptr[1] = __alloc_percpu(mibsize, align);
1523 if (!ptr[1]) { 1524 if (!ptr[1]) {
@@ -1561,6 +1562,8 @@ static const struct net_protocol icmp_protocol = {
1561 1562
1562static __net_init int ipv4_mib_init_net(struct net *net) 1563static __net_init int ipv4_mib_init_net(struct net *net)
1563{ 1564{
1565 int i;
1566
1564 if (snmp_mib_init((void __percpu **)net->mib.tcp_statistics, 1567 if (snmp_mib_init((void __percpu **)net->mib.tcp_statistics,
1565 sizeof(struct tcp_mib), 1568 sizeof(struct tcp_mib),
1566 __alignof__(struct tcp_mib)) < 0) 1569 __alignof__(struct tcp_mib)) < 0)
@@ -1569,6 +1572,17 @@ static __net_init int ipv4_mib_init_net(struct net *net)
1569 sizeof(struct ipstats_mib), 1572 sizeof(struct ipstats_mib),
1570 __alignof__(struct ipstats_mib)) < 0) 1573 __alignof__(struct ipstats_mib)) < 0)
1571 goto err_ip_mib; 1574 goto err_ip_mib;
1575
1576 for_each_possible_cpu(i) {
1577 struct ipstats_mib *af_inet_stats;
1578 af_inet_stats = per_cpu_ptr(net->mib.ip_statistics[0], i);
1579 u64_stats_init(&af_inet_stats->syncp);
1580#if SNMP_ARRAY_SZ == 2
1581 af_inet_stats = per_cpu_ptr(net->mib.ip_statistics[1], i);
1582 u64_stats_init(&af_inet_stats->syncp);
1583#endif
1584 }
1585
1572 if (snmp_mib_init((void __percpu **)net->mib.net_statistics, 1586 if (snmp_mib_init((void __percpu **)net->mib.net_statistics,
1573 sizeof(struct linux_mib), 1587 sizeof(struct linux_mib),
1574 __alignof__(struct linux_mib)) < 0) 1588 __alignof__(struct linux_mib)) < 0)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 63a6d6d6b875..caf01176a5e4 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -976,13 +976,19 @@ int ip_tunnel_init(struct net_device *dev)
976{ 976{
977 struct ip_tunnel *tunnel = netdev_priv(dev); 977 struct ip_tunnel *tunnel = netdev_priv(dev);
978 struct iphdr *iph = &tunnel->parms.iph; 978 struct iphdr *iph = &tunnel->parms.iph;
979 int err; 979 int i, err;
980 980
981 dev->destructor = ip_tunnel_dev_free; 981 dev->destructor = ip_tunnel_dev_free;
982 dev->tstats = alloc_percpu(struct pcpu_tstats); 982 dev->tstats = alloc_percpu(struct pcpu_tstats);
983 if (!dev->tstats) 983 if (!dev->tstats)
984 return -ENOMEM; 984 return -ENOMEM;
985 985
986 for_each_possible_cpu(i) {
987 struct pcpu_tstats *ipt_stats;
988 ipt_stats = per_cpu_ptr(dev->tstats, i);
989 u64_stats_init(&ipt_stats->syncp);
990 }
991
986 err = gro_cells_init(&tunnel->gro_cells, dev); 992 err = gro_cells_init(&tunnel->gro_cells, dev);
987 if (err) { 993 if (err) {
988 free_percpu(dev->tstats); 994 free_percpu(dev->tstats);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index cd3fb301da38..d62d589bb622 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -281,10 +281,24 @@ static void addrconf_mod_dad_timer(struct inet6_ifaddr *ifp,
281 281
282static int snmp6_alloc_dev(struct inet6_dev *idev) 282static int snmp6_alloc_dev(struct inet6_dev *idev)
283{ 283{
284 int i;
285
284 if (snmp_mib_init((void __percpu **)idev->stats.ipv6, 286 if (snmp_mib_init((void __percpu **)idev->stats.ipv6,
285 sizeof(struct ipstats_mib), 287 sizeof(struct ipstats_mib),
286 __alignof__(struct ipstats_mib)) < 0) 288 __alignof__(struct ipstats_mib)) < 0)
287 goto err_ip; 289 goto err_ip;
290
291 for_each_possible_cpu(i) {
292 struct ipstats_mib *addrconf_stats;
293 addrconf_stats = per_cpu_ptr(idev->stats.ipv6[0], i);
294 u64_stats_init(&addrconf_stats->syncp);
295#if SNMP_ARRAY_SZ == 2
296 addrconf_stats = per_cpu_ptr(idev->stats.ipv6[1], i);
297 u64_stats_init(&addrconf_stats->syncp);
298#endif
299 }
300
301
288 idev->stats.icmpv6dev = kzalloc(sizeof(struct icmpv6_mib_device), 302 idev->stats.icmpv6dev = kzalloc(sizeof(struct icmpv6_mib_device),
289 GFP_KERNEL); 303 GFP_KERNEL);
290 if (!idev->stats.icmpv6dev) 304 if (!idev->stats.icmpv6dev)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 7c96100b021e..a8f8559b3dce 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -719,6 +719,8 @@ static void ipv6_packet_cleanup(void)
719 719
720static int __net_init ipv6_init_mibs(struct net *net) 720static int __net_init ipv6_init_mibs(struct net *net)
721{ 721{
722 int i;
723
722 if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6, 724 if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6,
723 sizeof(struct udp_mib), 725 sizeof(struct udp_mib),
724 __alignof__(struct udp_mib)) < 0) 726 __alignof__(struct udp_mib)) < 0)
@@ -731,6 +733,18 @@ static int __net_init ipv6_init_mibs(struct net *net)
731 sizeof(struct ipstats_mib), 733 sizeof(struct ipstats_mib),
732 __alignof__(struct ipstats_mib)) < 0) 734 __alignof__(struct ipstats_mib)) < 0)
733 goto err_ip_mib; 735 goto err_ip_mib;
736
737 for_each_possible_cpu(i) {
738 struct ipstats_mib *af_inet6_stats;
739 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics[0], i);
740 u64_stats_init(&af_inet6_stats->syncp);
741#if SNMP_ARRAY_SZ == 2
742 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics[1], i);
743 u64_stats_init(&af_inet6_stats->syncp);
744#endif
745 }
746
747
734 if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics, 748 if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics,
735 sizeof(struct icmpv6_mib), 749 sizeof(struct icmpv6_mib),
736 __alignof__(struct icmpv6_mib)) < 0) 750 __alignof__(struct icmpv6_mib)) < 0)
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index bf4a9a084de5..8acb28621f9c 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1252,6 +1252,7 @@ static void ip6gre_tunnel_setup(struct net_device *dev)
1252static int ip6gre_tunnel_init(struct net_device *dev) 1252static int ip6gre_tunnel_init(struct net_device *dev)
1253{ 1253{
1254 struct ip6_tnl *tunnel; 1254 struct ip6_tnl *tunnel;
1255 int i;
1255 1256
1256 tunnel = netdev_priv(dev); 1257 tunnel = netdev_priv(dev);
1257 1258
@@ -1269,6 +1270,13 @@ static int ip6gre_tunnel_init(struct net_device *dev)
1269 if (!dev->tstats) 1270 if (!dev->tstats)
1270 return -ENOMEM; 1271 return -ENOMEM;
1271 1272
1273 for_each_possible_cpu(i) {
1274 struct pcpu_tstats *ip6gre_tunnel_stats;
1275 ip6gre_tunnel_stats = per_cpu_ptr(dev->tstats, i);
1276 u64_stats_init(&ip6gre_tunnel_stats->syncp);
1277 }
1278
1279
1272 return 0; 1280 return 0;
1273} 1281}
1274 1282
@@ -1449,6 +1457,7 @@ static void ip6gre_netlink_parms(struct nlattr *data[],
1449static int ip6gre_tap_init(struct net_device *dev) 1457static int ip6gre_tap_init(struct net_device *dev)
1450{ 1458{
1451 struct ip6_tnl *tunnel; 1459 struct ip6_tnl *tunnel;
1460 int i;
1452 1461
1453 tunnel = netdev_priv(dev); 1462 tunnel = netdev_priv(dev);
1454 1463
@@ -1462,6 +1471,12 @@ static int ip6gre_tap_init(struct net_device *dev)
1462 if (!dev->tstats) 1471 if (!dev->tstats)
1463 return -ENOMEM; 1472 return -ENOMEM;
1464 1473
1474 for_each_possible_cpu(i) {
1475 struct pcpu_tstats *ip6gre_tap_stats;
1476 ip6gre_tap_stats = per_cpu_ptr(dev->tstats, i);
1477 u64_stats_init(&ip6gre_tap_stats->syncp);
1478 }
1479
1465 return 0; 1480 return 0;
1466} 1481}
1467 1482
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 583b77e2f69b..df1fa58528c6 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1494,12 +1494,19 @@ static inline int
1494ip6_tnl_dev_init_gen(struct net_device *dev) 1494ip6_tnl_dev_init_gen(struct net_device *dev)
1495{ 1495{
1496 struct ip6_tnl *t = netdev_priv(dev); 1496 struct ip6_tnl *t = netdev_priv(dev);
1497 int i;
1497 1498
1498 t->dev = dev; 1499 t->dev = dev;
1499 t->net = dev_net(dev); 1500 t->net = dev_net(dev);
1500 dev->tstats = alloc_percpu(struct pcpu_tstats); 1501 dev->tstats = alloc_percpu(struct pcpu_tstats);
1501 if (!dev->tstats) 1502 if (!dev->tstats)
1502 return -ENOMEM; 1503 return -ENOMEM;
1504
1505 for_each_possible_cpu(i) {
1506 struct pcpu_tstats *ip6_tnl_stats;
1507 ip6_tnl_stats = per_cpu_ptr(dev->tstats, i);
1508 u64_stats_init(&ip6_tnl_stats->syncp);
1509 }
1503 return 0; 1510 return 0;
1504} 1511}
1505 1512
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 19269453a8ea..365dc5473eb2 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1310,6 +1310,7 @@ static void ipip6_tunnel_setup(struct net_device *dev)
1310static int ipip6_tunnel_init(struct net_device *dev) 1310static int ipip6_tunnel_init(struct net_device *dev)
1311{ 1311{
1312 struct ip_tunnel *tunnel = netdev_priv(dev); 1312 struct ip_tunnel *tunnel = netdev_priv(dev);
1313 int i;
1313 1314
1314 tunnel->dev = dev; 1315 tunnel->dev = dev;
1315 tunnel->net = dev_net(dev); 1316 tunnel->net = dev_net(dev);
@@ -1322,6 +1323,12 @@ static int ipip6_tunnel_init(struct net_device *dev)
1322 if (!dev->tstats) 1323 if (!dev->tstats)
1323 return -ENOMEM; 1324 return -ENOMEM;
1324 1325
1326 for_each_possible_cpu(i) {
1327 struct pcpu_tstats *ipip6_tunnel_stats;
1328 ipip6_tunnel_stats = per_cpu_ptr(dev->tstats, i);
1329 u64_stats_init(&ipip6_tunnel_stats->syncp);
1330 }
1331
1325 return 0; 1332 return 0;
1326} 1333}
1327 1334
@@ -1331,6 +1338,7 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
1331 struct iphdr *iph = &tunnel->parms.iph; 1338 struct iphdr *iph = &tunnel->parms.iph;
1332 struct net *net = dev_net(dev); 1339 struct net *net = dev_net(dev);
1333 struct sit_net *sitn = net_generic(net, sit_net_id); 1340 struct sit_net *sitn = net_generic(net, sit_net_id);
1341 int i;
1334 1342
1335 tunnel->dev = dev; 1343 tunnel->dev = dev;
1336 tunnel->net = dev_net(dev); 1344 tunnel->net = dev_net(dev);
@@ -1344,6 +1352,13 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
1344 dev->tstats = alloc_percpu(struct pcpu_tstats); 1352 dev->tstats = alloc_percpu(struct pcpu_tstats);
1345 if (!dev->tstats) 1353 if (!dev->tstats)
1346 return -ENOMEM; 1354 return -ENOMEM;
1355
1356 for_each_possible_cpu(i) {
1357 struct pcpu_tstats *ipip6_fb_stats;
1358 ipip6_fb_stats = per_cpu_ptr(dev->tstats, i);
1359 u64_stats_init(&ipip6_fb_stats->syncp);
1360 }
1361
1347 dev_hold(dev); 1362 dev_hold(dev);
1348 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); 1363 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1349 return 0; 1364 return 0;
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index a3df9bddc4f7..3825725907f6 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -842,7 +842,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
842 struct ip_vs_dest **dest_p) 842 struct ip_vs_dest **dest_p)
843{ 843{
844 struct ip_vs_dest *dest; 844 struct ip_vs_dest *dest;
845 unsigned int atype; 845 unsigned int atype, i;
846 846
847 EnterFunction(2); 847 EnterFunction(2);
848 848
@@ -869,6 +869,12 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
869 if (!dest->stats.cpustats) 869 if (!dest->stats.cpustats)
870 goto err_alloc; 870 goto err_alloc;
871 871
872 for_each_possible_cpu(i) {
873 struct ip_vs_cpu_stats *ip_vs_dest_stats;
874 ip_vs_dest_stats = per_cpu_ptr(dest->stats.cpustats, i);
875 u64_stats_init(&ip_vs_dest_stats->syncp);
876 }
877
872 dest->af = svc->af; 878 dest->af = svc->af;
873 dest->protocol = svc->protocol; 879 dest->protocol = svc->protocol;
874 dest->vaddr = svc->addr; 880 dest->vaddr = svc->addr;
@@ -1134,7 +1140,7 @@ static int
1134ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u, 1140ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u,
1135 struct ip_vs_service **svc_p) 1141 struct ip_vs_service **svc_p)
1136{ 1142{
1137 int ret = 0; 1143 int ret = 0, i;
1138 struct ip_vs_scheduler *sched = NULL; 1144 struct ip_vs_scheduler *sched = NULL;
1139 struct ip_vs_pe *pe = NULL; 1145 struct ip_vs_pe *pe = NULL;
1140 struct ip_vs_service *svc = NULL; 1146 struct ip_vs_service *svc = NULL;
@@ -1184,6 +1190,13 @@ ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u,
1184 goto out_err; 1190 goto out_err;
1185 } 1191 }
1186 1192
1193 for_each_possible_cpu(i) {
1194 struct ip_vs_cpu_stats *ip_vs_stats;
1195 ip_vs_stats = per_cpu_ptr(svc->stats.cpustats, i);
1196 u64_stats_init(&ip_vs_stats->syncp);
1197 }
1198
1199
1187 /* I'm the first user of the service */ 1200 /* I'm the first user of the service */
1188 atomic_set(&svc->refcnt, 0); 1201 atomic_set(&svc->refcnt, 0);
1189 1202
@@ -3780,7 +3793,7 @@ static struct notifier_block ip_vs_dst_notifier = {
3780 3793
3781int __net_init ip_vs_control_net_init(struct net *net) 3794int __net_init ip_vs_control_net_init(struct net *net)
3782{ 3795{
3783 int idx; 3796 int i, idx;
3784 struct netns_ipvs *ipvs = net_ipvs(net); 3797 struct netns_ipvs *ipvs = net_ipvs(net);
3785 3798
3786 /* Initialize rs_table */ 3799 /* Initialize rs_table */
@@ -3799,6 +3812,12 @@ int __net_init ip_vs_control_net_init(struct net *net)
3799 if (!ipvs->tot_stats.cpustats) 3812 if (!ipvs->tot_stats.cpustats)
3800 return -ENOMEM; 3813 return -ENOMEM;
3801 3814
3815 for_each_possible_cpu(i) {
3816 struct ip_vs_cpu_stats *ipvs_tot_stats;
3817 ipvs_tot_stats = per_cpu_ptr(ipvs->tot_stats.cpustats, i);
3818 u64_stats_init(&ipvs_tot_stats->syncp);
3819 }
3820
3802 spin_lock_init(&ipvs->tot_stats.lock); 3821 spin_lock_init(&ipvs->tot_stats.lock);
3803 3822
3804 proc_create("ip_vs", 0, net->proc_net, &ip_vs_info_fops); 3823 proc_create("ip_vs", 0, net->proc_net, &ip_vs_info_fops);
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 2aa13bd7f2b2..b92553c02279 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1698,6 +1698,12 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
1698 goto err_destroy_table; 1698 goto err_destroy_table;
1699 } 1699 }
1700 1700
1701 for_each_possible_cpu(i) {
1702 struct dp_stats_percpu *dpath_stats;
1703 dpath_stats = per_cpu_ptr(dp->stats_percpu, i);
1704 u64_stats_init(&dpath_stats->sync);
1705 }
1706
1701 dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head), 1707 dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
1702 GFP_KERNEL); 1708 GFP_KERNEL);
1703 if (!dp->ports) { 1709 if (!dp->ports) {
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 6f65dbe13812..d830a95f03a4 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -118,6 +118,7 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
118{ 118{
119 struct vport *vport; 119 struct vport *vport;
120 size_t alloc_size; 120 size_t alloc_size;
121 int i;
121 122
122 alloc_size = sizeof(struct vport); 123 alloc_size = sizeof(struct vport);
123 if (priv_size) { 124 if (priv_size) {
@@ -141,6 +142,13 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
141 return ERR_PTR(-ENOMEM); 142 return ERR_PTR(-ENOMEM);
142 } 143 }
143 144
145 for_each_possible_cpu(i) {
146 struct pcpu_tstats *vport_stats;
147 vport_stats = per_cpu_ptr(vport->percpu_stats, i);
148 u64_stats_init(&vport_stats->syncp);
149 }
150
151
144 spin_lock_init(&vport->stats_lock); 152 spin_lock_init(&vport->stats_lock);
145 153
146 return vport; 154 return vport;