diff options
-rw-r--r-- | drivers/net/dummy.c | 8 | ||||
-rw-r--r-- | drivers/net/ethernet/marvell/mvneta.c | 9 | ||||
-rw-r--r-- | drivers/net/loopback.c | 9 | ||||
-rw-r--r-- | drivers/net/macvlan.c | 9 | ||||
-rw-r--r-- | drivers/net/nlmon.c | 11 | ||||
-rw-r--r-- | drivers/net/team/team.c | 8 | ||||
-rw-r--r-- | drivers/net/veth.c | 11 | ||||
-rw-r--r-- | drivers/net/vxlan.c | 10 | ||||
-rw-r--r-- | drivers/net/xen-netfront.c | 8 | ||||
-rw-r--r-- | include/linux/netdevice.h | 14 | ||||
-rw-r--r-- | net/8021q/vlan_dev.c | 11 | ||||
-rw-r--r-- | net/bridge/br_device.c | 9 | ||||
-rw-r--r-- | net/ipv4/ip_tunnel.c | 10 | ||||
-rw-r--r-- | net/ipv6/ip6_gre.c | 9 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 9 | ||||
-rw-r--r-- | net/ipv6/ip6_vti.c | 8 | ||||
-rw-r--r-- | net/ipv6/sit.c | 18 | ||||
-rw-r--r-- | net/openvswitch/datapath.c | 8 | ||||
-rw-r--r-- | net/openvswitch/vport.c | 10 |
19 files changed, 35 insertions, 154 deletions
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index bd8f84b0b894..1656317c96f8 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c | |||
@@ -88,16 +88,10 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
88 | 88 | ||
89 | static int dummy_dev_init(struct net_device *dev) | 89 | static int dummy_dev_init(struct net_device *dev) |
90 | { | 90 | { |
91 | int i; | 91 | dev->dstats = netdev_alloc_pcpu_stats(struct pcpu_dstats); |
92 | dev->dstats = alloc_percpu(struct pcpu_dstats); | ||
93 | if (!dev->dstats) | 92 | if (!dev->dstats) |
94 | return -ENOMEM; | 93 | return -ENOMEM; |
95 | 94 | ||
96 | for_each_possible_cpu(i) { | ||
97 | struct pcpu_dstats *dstats; | ||
98 | dstats = per_cpu_ptr(dev->dstats, i); | ||
99 | u64_stats_init(&dstats->syncp); | ||
100 | } | ||
101 | return 0; | 95 | return 0; |
102 | } | 96 | } |
103 | 97 | ||
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index f418f4f20f94..12c6a66e54d1 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c | |||
@@ -2784,7 +2784,6 @@ static int mvneta_probe(struct platform_device *pdev) | |||
2784 | const char *mac_from; | 2784 | const char *mac_from; |
2785 | int phy_mode; | 2785 | int phy_mode; |
2786 | int err; | 2786 | int err; |
2787 | int cpu; | ||
2788 | 2787 | ||
2789 | /* Our multiqueue support is not complete, so for now, only | 2788 | /* Our multiqueue support is not complete, so for now, only |
2790 | * allow the usage of the first RX queue | 2789 | * allow the usage of the first RX queue |
@@ -2845,18 +2844,12 @@ static int mvneta_probe(struct platform_device *pdev) | |||
2845 | } | 2844 | } |
2846 | 2845 | ||
2847 | /* Alloc per-cpu stats */ | 2846 | /* Alloc per-cpu stats */ |
2848 | pp->stats = alloc_percpu(struct mvneta_pcpu_stats); | 2847 | pp->stats = netdev_alloc_pcpu_stats(struct mvneta_pcpu_stats); |
2849 | if (!pp->stats) { | 2848 | if (!pp->stats) { |
2850 | err = -ENOMEM; | 2849 | err = -ENOMEM; |
2851 | goto err_unmap; | 2850 | goto err_unmap; |
2852 | } | 2851 | } |
2853 | 2852 | ||
2854 | for_each_possible_cpu(cpu) { | ||
2855 | struct mvneta_pcpu_stats *stats; | ||
2856 | stats = per_cpu_ptr(pp->stats, cpu); | ||
2857 | u64_stats_init(&stats->syncp); | ||
2858 | } | ||
2859 | |||
2860 | dt_mac_addr = of_get_mac_address(dn); | 2853 | dt_mac_addr = of_get_mac_address(dn); |
2861 | if (dt_mac_addr) { | 2854 | if (dt_mac_addr) { |
2862 | mac_from = "device tree"; | 2855 | mac_from = "device tree"; |
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index e7c1d5f8ab51..771c9bfa7d31 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -136,16 +136,9 @@ static const struct ethtool_ops loopback_ethtool_ops = { | |||
136 | 136 | ||
137 | static int loopback_dev_init(struct net_device *dev) | 137 | static int loopback_dev_init(struct net_device *dev) |
138 | { | 138 | { |
139 | int i; | 139 | dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats); |
140 | dev->lstats = alloc_percpu(struct pcpu_lstats); | ||
141 | if (!dev->lstats) | 140 | if (!dev->lstats) |
142 | return -ENOMEM; | 141 | return -ENOMEM; |
143 | |||
144 | for_each_possible_cpu(i) { | ||
145 | struct pcpu_lstats *lb_stats; | ||
146 | lb_stats = per_cpu_ptr(dev->lstats, i); | ||
147 | u64_stats_init(&lb_stats->syncp); | ||
148 | } | ||
149 | return 0; | 142 | return 0; |
150 | } | 143 | } |
151 | 144 | ||
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 8433de4509c7..25685e3eb472 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -534,7 +534,6 @@ static int macvlan_init(struct net_device *dev) | |||
534 | { | 534 | { |
535 | struct macvlan_dev *vlan = netdev_priv(dev); | 535 | struct macvlan_dev *vlan = netdev_priv(dev); |
536 | const struct net_device *lowerdev = vlan->lowerdev; | 536 | const struct net_device *lowerdev = vlan->lowerdev; |
537 | int i; | ||
538 | 537 | ||
539 | dev->state = (dev->state & ~MACVLAN_STATE_MASK) | | 538 | dev->state = (dev->state & ~MACVLAN_STATE_MASK) | |
540 | (lowerdev->state & MACVLAN_STATE_MASK); | 539 | (lowerdev->state & MACVLAN_STATE_MASK); |
@@ -546,16 +545,10 @@ static int macvlan_init(struct net_device *dev) | |||
546 | 545 | ||
547 | macvlan_set_lockdep_class(dev); | 546 | macvlan_set_lockdep_class(dev); |
548 | 547 | ||
549 | vlan->pcpu_stats = alloc_percpu(struct vlan_pcpu_stats); | 548 | vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); |
550 | if (!vlan->pcpu_stats) | 549 | if (!vlan->pcpu_stats) |
551 | return -ENOMEM; | 550 | return -ENOMEM; |
552 | 551 | ||
553 | for_each_possible_cpu(i) { | ||
554 | struct vlan_pcpu_stats *mvlstats; | ||
555 | mvlstats = per_cpu_ptr(vlan->pcpu_stats, i); | ||
556 | u64_stats_init(&mvlstats->syncp); | ||
557 | } | ||
558 | |||
559 | return 0; | 552 | return 0; |
560 | } | 553 | } |
561 | 554 | ||
diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c index d2bb12bfabd5..14ce7de6a933 100644 --- a/drivers/net/nlmon.c +++ b/drivers/net/nlmon.c | |||
@@ -47,16 +47,7 @@ static int nlmon_change_mtu(struct net_device *dev, int new_mtu) | |||
47 | 47 | ||
48 | static int nlmon_dev_init(struct net_device *dev) | 48 | static int nlmon_dev_init(struct net_device *dev) |
49 | { | 49 | { |
50 | int i; | 50 | dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats); |
51 | |||
52 | dev->lstats = alloc_percpu(struct pcpu_lstats); | ||
53 | |||
54 | for_each_possible_cpu(i) { | ||
55 | struct pcpu_lstats *nlmstats; | ||
56 | nlmstats = per_cpu_ptr(dev->lstats, i); | ||
57 | u64_stats_init(&nlmstats->syncp); | ||
58 | } | ||
59 | |||
60 | return dev->lstats == NULL ? -ENOMEM : 0; | 51 | return dev->lstats == NULL ? -ENOMEM : 0; |
61 | } | 52 | } |
62 | 53 | ||
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 28407426fd6f..adb46de7c90d 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
@@ -1540,16 +1540,10 @@ static int team_init(struct net_device *dev) | |||
1540 | mutex_init(&team->lock); | 1540 | mutex_init(&team->lock); |
1541 | team_set_no_mode(team); | 1541 | team_set_no_mode(team); |
1542 | 1542 | ||
1543 | team->pcpu_stats = alloc_percpu(struct team_pcpu_stats); | 1543 | team->pcpu_stats = netdev_alloc_pcpu_stats(struct team_pcpu_stats); |
1544 | if (!team->pcpu_stats) | 1544 | if (!team->pcpu_stats) |
1545 | return -ENOMEM; | 1545 | return -ENOMEM; |
1546 | 1546 | ||
1547 | for_each_possible_cpu(i) { | ||
1548 | struct team_pcpu_stats *team_stats; | ||
1549 | team_stats = per_cpu_ptr(team->pcpu_stats, i); | ||
1550 | u64_stats_init(&team_stats->syncp); | ||
1551 | } | ||
1552 | |||
1553 | for (i = 0; i < TEAM_PORT_HASHENTRIES; i++) | 1547 | for (i = 0; i < TEAM_PORT_HASHENTRIES; i++) |
1554 | INIT_HLIST_HEAD(&team->en_port_hlist[i]); | 1548 | INIT_HLIST_HEAD(&team->en_port_hlist[i]); |
1555 | INIT_LIST_HEAD(&team->port_list); | 1549 | INIT_LIST_HEAD(&team->port_list); |
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 2ec2041b62d4..91c33c1d3c9c 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -235,18 +235,9 @@ static int veth_change_mtu(struct net_device *dev, int new_mtu) | |||
235 | 235 | ||
236 | static int veth_dev_init(struct net_device *dev) | 236 | static int veth_dev_init(struct net_device *dev) |
237 | { | 237 | { |
238 | int i; | 238 | dev->vstats = netdev_alloc_pcpu_stats(struct pcpu_vstats); |
239 | |||
240 | dev->vstats = alloc_percpu(struct pcpu_vstats); | ||
241 | if (!dev->vstats) | 239 | if (!dev->vstats) |
242 | return -ENOMEM; | 240 | return -ENOMEM; |
243 | |||
244 | for_each_possible_cpu(i) { | ||
245 | struct pcpu_vstats *veth_stats; | ||
246 | veth_stats = per_cpu_ptr(dev->vstats, i); | ||
247 | u64_stats_init(&veth_stats->syncp); | ||
248 | } | ||
249 | |||
250 | return 0; | 241 | return 0; |
251 | } | 242 | } |
252 | 243 | ||
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index b0f705c2378f..dec9820bc182 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -1978,19 +1978,11 @@ static int vxlan_init(struct net_device *dev) | |||
1978 | struct vxlan_dev *vxlan = netdev_priv(dev); | 1978 | struct vxlan_dev *vxlan = netdev_priv(dev); |
1979 | struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); | 1979 | struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); |
1980 | struct vxlan_sock *vs; | 1980 | struct vxlan_sock *vs; |
1981 | int i; | ||
1982 | 1981 | ||
1983 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 1982 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1984 | if (!dev->tstats) | 1983 | if (!dev->tstats) |
1985 | return -ENOMEM; | 1984 | return -ENOMEM; |
1986 | 1985 | ||
1987 | for_each_possible_cpu(i) { | ||
1988 | struct pcpu_sw_netstats *vxlan_stats; | ||
1989 | vxlan_stats = per_cpu_ptr(dev->tstats, i); | ||
1990 | u64_stats_init(&vxlan_stats->syncp); | ||
1991 | } | ||
1992 | |||
1993 | |||
1994 | spin_lock(&vn->sock_lock); | 1986 | spin_lock(&vn->sock_lock); |
1995 | vs = vxlan_find_sock(dev_net(dev), vxlan->dst_port); | 1987 | vs = vxlan_find_sock(dev_net(dev), vxlan->dst_port); |
1996 | if (vs) { | 1988 | if (vs) { |
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index f9daa9e183f2..2b62d799bfd8 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -1281,16 +1281,10 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) | |||
1281 | np->rx_refill_timer.function = rx_refill_timeout; | 1281 | np->rx_refill_timer.function = rx_refill_timeout; |
1282 | 1282 | ||
1283 | err = -ENOMEM; | 1283 | err = -ENOMEM; |
1284 | np->stats = alloc_percpu(struct netfront_stats); | 1284 | np->stats = netdev_alloc_pcpu_stats(struct netfront_stats); |
1285 | if (np->stats == NULL) | 1285 | if (np->stats == NULL) |
1286 | goto exit; | 1286 | goto exit; |
1287 | 1287 | ||
1288 | for_each_possible_cpu(i) { | ||
1289 | struct netfront_stats *xen_nf_stats; | ||
1290 | xen_nf_stats = per_cpu_ptr(np->stats, i); | ||
1291 | u64_stats_init(&xen_nf_stats->syncp); | ||
1292 | } | ||
1293 | |||
1294 | /* Initialise tx_skbs as a free chain containing every entry. */ | 1288 | /* Initialise tx_skbs as a free chain containing every entry. */ |
1295 | np->tx_skb_freelist = 0; | 1289 | np->tx_skb_freelist = 0; |
1296 | for (i = 0; i < NET_TX_RING_SIZE; i++) { | 1290 | for (i = 0; i < NET_TX_RING_SIZE; i++) { |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 440a02ee6f92..430c51aed6a4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1726,6 +1726,20 @@ struct pcpu_sw_netstats { | |||
1726 | struct u64_stats_sync syncp; | 1726 | struct u64_stats_sync syncp; |
1727 | }; | 1727 | }; |
1728 | 1728 | ||
1729 | #define netdev_alloc_pcpu_stats(type) \ | ||
1730 | ({ \ | ||
1731 | typeof(type) *pcpu_stats = alloc_percpu(type); \ | ||
1732 | if (pcpu_stats) { \ | ||
1733 | int i; \ | ||
1734 | for_each_possible_cpu(i) { \ | ||
1735 | typeof(type) *stat; \ | ||
1736 | stat = per_cpu_ptr(pcpu_stats, i); \ | ||
1737 | u64_stats_init(&stat->syncp); \ | ||
1738 | } \ | ||
1739 | } \ | ||
1740 | pcpu_stats; \ | ||
1741 | }) | ||
1742 | |||
1729 | #include <linux/notifier.h> | 1743 | #include <linux/notifier.h> |
1730 | 1744 | ||
1731 | /* netdevice notifier chain. Please remember to update the rtnetlink | 1745 | /* netdevice notifier chain. Please remember to update the rtnetlink |
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index de51c48c4393..566adbf5c506 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -556,7 +556,7 @@ static const struct net_device_ops vlan_netdev_ops; | |||
556 | static int vlan_dev_init(struct net_device *dev) | 556 | static int vlan_dev_init(struct net_device *dev) |
557 | { | 557 | { |
558 | struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; | 558 | struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; |
559 | int subclass = 0, i; | 559 | int subclass = 0; |
560 | 560 | ||
561 | netif_carrier_off(dev); | 561 | netif_carrier_off(dev); |
562 | 562 | ||
@@ -606,17 +606,10 @@ static int vlan_dev_init(struct net_device *dev) | |||
606 | 606 | ||
607 | vlan_dev_set_lockdep_class(dev, subclass); | 607 | vlan_dev_set_lockdep_class(dev, subclass); |
608 | 608 | ||
609 | vlan_dev_priv(dev)->vlan_pcpu_stats = alloc_percpu(struct vlan_pcpu_stats); | 609 | vlan_dev_priv(dev)->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); |
610 | if (!vlan_dev_priv(dev)->vlan_pcpu_stats) | 610 | if (!vlan_dev_priv(dev)->vlan_pcpu_stats) |
611 | return -ENOMEM; | 611 | return -ENOMEM; |
612 | 612 | ||
613 | for_each_possible_cpu(i) { | ||
614 | struct vlan_pcpu_stats *vlan_stat; | ||
615 | vlan_stat = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i); | ||
616 | u64_stats_init(&vlan_stat->syncp); | ||
617 | } | ||
618 | |||
619 | |||
620 | return 0; | 613 | return 0; |
621 | } | 614 | } |
622 | 615 | ||
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 63f0455c0bc3..bf34451743a1 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -88,18 +88,11 @@ out: | |||
88 | static int br_dev_init(struct net_device *dev) | 88 | static 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; | ||
92 | 91 | ||
93 | br->stats = alloc_percpu(struct pcpu_sw_netstats); | 92 | br->stats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
94 | if (!br->stats) | 93 | if (!br->stats) |
95 | return -ENOMEM; | 94 | return -ENOMEM; |
96 | 95 | ||
97 | for_each_possible_cpu(i) { | ||
98 | struct pcpu_sw_netstats *br_dev_stats; | ||
99 | br_dev_stats = per_cpu_ptr(br->stats, i); | ||
100 | u64_stats_init(&br_dev_stats->syncp); | ||
101 | } | ||
102 | |||
103 | return 0; | 96 | return 0; |
104 | } | 97 | } |
105 | 98 | ||
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 50228be5c17b..3400d737adc6 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c | |||
@@ -1041,19 +1041,13 @@ int ip_tunnel_init(struct net_device *dev) | |||
1041 | { | 1041 | { |
1042 | struct ip_tunnel *tunnel = netdev_priv(dev); | 1042 | struct ip_tunnel *tunnel = netdev_priv(dev); |
1043 | struct iphdr *iph = &tunnel->parms.iph; | 1043 | struct iphdr *iph = &tunnel->parms.iph; |
1044 | int i, err; | 1044 | int err; |
1045 | 1045 | ||
1046 | dev->destructor = ip_tunnel_dev_free; | 1046 | dev->destructor = ip_tunnel_dev_free; |
1047 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 1047 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1048 | if (!dev->tstats) | 1048 | if (!dev->tstats) |
1049 | return -ENOMEM; | 1049 | return -ENOMEM; |
1050 | 1050 | ||
1051 | for_each_possible_cpu(i) { | ||
1052 | struct pcpu_sw_netstats *ipt_stats; | ||
1053 | ipt_stats = per_cpu_ptr(dev->tstats, i); | ||
1054 | u64_stats_init(&ipt_stats->syncp); | ||
1055 | } | ||
1056 | |||
1057 | tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst); | 1051 | tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst); |
1058 | if (!tunnel->dst_cache) { | 1052 | if (!tunnel->dst_cache) { |
1059 | free_percpu(dev->tstats); | 1053 | free_percpu(dev->tstats); |
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index f3ffb43f59c0..c98338b81d30 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -1454,7 +1454,6 @@ static void ip6gre_netlink_parms(struct nlattr *data[], | |||
1454 | static int ip6gre_tap_init(struct net_device *dev) | 1454 | static int ip6gre_tap_init(struct net_device *dev) |
1455 | { | 1455 | { |
1456 | struct ip6_tnl *tunnel; | 1456 | struct ip6_tnl *tunnel; |
1457 | int i; | ||
1458 | 1457 | ||
1459 | tunnel = netdev_priv(dev); | 1458 | tunnel = netdev_priv(dev); |
1460 | 1459 | ||
@@ -1464,16 +1463,10 @@ static int ip6gre_tap_init(struct net_device *dev) | |||
1464 | 1463 | ||
1465 | ip6gre_tnl_link_config(tunnel, 1); | 1464 | ip6gre_tnl_link_config(tunnel, 1); |
1466 | 1465 | ||
1467 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 1466 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1468 | if (!dev->tstats) | 1467 | if (!dev->tstats) |
1469 | return -ENOMEM; | 1468 | return -ENOMEM; |
1470 | 1469 | ||
1471 | for_each_possible_cpu(i) { | ||
1472 | struct pcpu_sw_netstats *ip6gre_tap_stats; | ||
1473 | ip6gre_tap_stats = per_cpu_ptr(dev->tstats, i); | ||
1474 | u64_stats_init(&ip6gre_tap_stats->syncp); | ||
1475 | } | ||
1476 | |||
1477 | return 0; | 1470 | return 0; |
1478 | } | 1471 | } |
1479 | 1472 | ||
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 5db8d310f9c0..8ad59f4811df 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -1502,19 +1502,12 @@ static inline int | |||
1502 | ip6_tnl_dev_init_gen(struct net_device *dev) | 1502 | ip6_tnl_dev_init_gen(struct net_device *dev) |
1503 | { | 1503 | { |
1504 | struct ip6_tnl *t = netdev_priv(dev); | 1504 | struct ip6_tnl *t = netdev_priv(dev); |
1505 | int i; | ||
1506 | 1505 | ||
1507 | t->dev = dev; | 1506 | t->dev = dev; |
1508 | t->net = dev_net(dev); | 1507 | t->net = dev_net(dev); |
1509 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 1508 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1510 | if (!dev->tstats) | 1509 | if (!dev->tstats) |
1511 | return -ENOMEM; | 1510 | return -ENOMEM; |
1512 | |||
1513 | for_each_possible_cpu(i) { | ||
1514 | struct pcpu_sw_netstats *ip6_tnl_stats; | ||
1515 | ip6_tnl_stats = per_cpu_ptr(dev->tstats, i); | ||
1516 | u64_stats_init(&ip6_tnl_stats->syncp); | ||
1517 | } | ||
1518 | return 0; | 1511 | return 0; |
1519 | } | 1512 | } |
1520 | 1513 | ||
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c index 2d19272b8cee..864914399391 100644 --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c | |||
@@ -731,18 +731,12 @@ static void vti6_dev_setup(struct net_device *dev) | |||
731 | static inline int vti6_dev_init_gen(struct net_device *dev) | 731 | static inline int vti6_dev_init_gen(struct net_device *dev) |
732 | { | 732 | { |
733 | struct ip6_tnl *t = netdev_priv(dev); | 733 | struct ip6_tnl *t = netdev_priv(dev); |
734 | int i; | ||
735 | 734 | ||
736 | t->dev = dev; | 735 | t->dev = dev; |
737 | t->net = dev_net(dev); | 736 | t->net = dev_net(dev); |
738 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 737 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
739 | if (!dev->tstats) | 738 | if (!dev->tstats) |
740 | return -ENOMEM; | 739 | return -ENOMEM; |
741 | for_each_possible_cpu(i) { | ||
742 | struct pcpu_sw_netstats *stats; | ||
743 | stats = per_cpu_ptr(dev->tstats, i); | ||
744 | u64_stats_init(&stats->syncp); | ||
745 | } | ||
746 | return 0; | 740 | return 0; |
747 | } | 741 | } |
748 | 742 | ||
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 3dfbcf1dcb1c..958027be0e94 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -1356,7 +1356,6 @@ static void ipip6_tunnel_setup(struct net_device *dev) | |||
1356 | static int ipip6_tunnel_init(struct net_device *dev) | 1356 | static int ipip6_tunnel_init(struct net_device *dev) |
1357 | { | 1357 | { |
1358 | struct ip_tunnel *tunnel = netdev_priv(dev); | 1358 | struct ip_tunnel *tunnel = netdev_priv(dev); |
1359 | int i; | ||
1360 | 1359 | ||
1361 | tunnel->dev = dev; | 1360 | tunnel->dev = dev; |
1362 | tunnel->net = dev_net(dev); | 1361 | tunnel->net = dev_net(dev); |
@@ -1365,16 +1364,10 @@ static int ipip6_tunnel_init(struct net_device *dev) | |||
1365 | memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); | 1364 | memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); |
1366 | 1365 | ||
1367 | ipip6_tunnel_bind_dev(dev); | 1366 | ipip6_tunnel_bind_dev(dev); |
1368 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 1367 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1369 | if (!dev->tstats) | 1368 | if (!dev->tstats) |
1370 | return -ENOMEM; | 1369 | return -ENOMEM; |
1371 | 1370 | ||
1372 | for_each_possible_cpu(i) { | ||
1373 | struct pcpu_sw_netstats *ipip6_tunnel_stats; | ||
1374 | ipip6_tunnel_stats = per_cpu_ptr(dev->tstats, i); | ||
1375 | u64_stats_init(&ipip6_tunnel_stats->syncp); | ||
1376 | } | ||
1377 | |||
1378 | return 0; | 1371 | return 0; |
1379 | } | 1372 | } |
1380 | 1373 | ||
@@ -1384,7 +1377,6 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev) | |||
1384 | struct iphdr *iph = &tunnel->parms.iph; | 1377 | struct iphdr *iph = &tunnel->parms.iph; |
1385 | struct net *net = dev_net(dev); | 1378 | struct net *net = dev_net(dev); |
1386 | struct sit_net *sitn = net_generic(net, sit_net_id); | 1379 | struct sit_net *sitn = net_generic(net, sit_net_id); |
1387 | int i; | ||
1388 | 1380 | ||
1389 | tunnel->dev = dev; | 1381 | tunnel->dev = dev; |
1390 | tunnel->net = dev_net(dev); | 1382 | tunnel->net = dev_net(dev); |
@@ -1395,16 +1387,10 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev) | |||
1395 | iph->ihl = 5; | 1387 | iph->ihl = 5; |
1396 | iph->ttl = 64; | 1388 | iph->ttl = 64; |
1397 | 1389 | ||
1398 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); | 1390 | dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
1399 | if (!dev->tstats) | 1391 | if (!dev->tstats) |
1400 | return -ENOMEM; | 1392 | return -ENOMEM; |
1401 | 1393 | ||
1402 | for_each_possible_cpu(i) { | ||
1403 | struct pcpu_sw_netstats *ipip6_fb_stats; | ||
1404 | ipip6_fb_stats = per_cpu_ptr(dev->tstats, i); | ||
1405 | u64_stats_init(&ipip6_fb_stats->syncp); | ||
1406 | } | ||
1407 | |||
1408 | dev_hold(dev); | 1394 | dev_hold(dev); |
1409 | rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); | 1395 | rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); |
1410 | return 0; | 1396 | return 0; |
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index e9a48baf8551..3a954067b6a4 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -1215,18 +1215,12 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) | |||
1215 | if (err) | 1215 | if (err) |
1216 | goto err_free_dp; | 1216 | goto err_free_dp; |
1217 | 1217 | ||
1218 | dp->stats_percpu = alloc_percpu(struct dp_stats_percpu); | 1218 | dp->stats_percpu = netdev_alloc_pcpu_stats(struct dp_stats_percpu); |
1219 | if (!dp->stats_percpu) { | 1219 | if (!dp->stats_percpu) { |
1220 | err = -ENOMEM; | 1220 | err = -ENOMEM; |
1221 | goto err_destroy_table; | 1221 | goto err_destroy_table; |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | for_each_possible_cpu(i) { | ||
1225 | struct dp_stats_percpu *dpath_stats; | ||
1226 | dpath_stats = per_cpu_ptr(dp->stats_percpu, i); | ||
1227 | u64_stats_init(&dpath_stats->sync); | ||
1228 | } | ||
1229 | |||
1230 | dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head), | 1224 | dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head), |
1231 | GFP_KERNEL); | 1225 | GFP_KERNEL); |
1232 | if (!dp->ports) { | 1226 | if (!dp->ports) { |
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index 208dd9a26dd1..3b4db3220456 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c | |||
@@ -121,7 +121,6 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, | |||
121 | { | 121 | { |
122 | struct vport *vport; | 122 | struct vport *vport; |
123 | size_t alloc_size; | 123 | size_t alloc_size; |
124 | int i; | ||
125 | 124 | ||
126 | alloc_size = sizeof(struct vport); | 125 | alloc_size = sizeof(struct vport); |
127 | if (priv_size) { | 126 | if (priv_size) { |
@@ -139,19 +138,12 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, | |||
139 | vport->ops = ops; | 138 | vport->ops = ops; |
140 | INIT_HLIST_NODE(&vport->dp_hash_node); | 139 | INIT_HLIST_NODE(&vport->dp_hash_node); |
141 | 140 | ||
142 | vport->percpu_stats = alloc_percpu(struct pcpu_sw_netstats); | 141 | vport->percpu_stats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); |
143 | if (!vport->percpu_stats) { | 142 | if (!vport->percpu_stats) { |
144 | kfree(vport); | 143 | kfree(vport); |
145 | return ERR_PTR(-ENOMEM); | 144 | return ERR_PTR(-ENOMEM); |
146 | } | 145 | } |
147 | 146 | ||
148 | for_each_possible_cpu(i) { | ||
149 | struct pcpu_sw_netstats *vport_stats; | ||
150 | vport_stats = per_cpu_ptr(vport->percpu_stats, i); | ||
151 | u64_stats_init(&vport_stats->syncp); | ||
152 | } | ||
153 | |||
154 | |||
155 | spin_lock_init(&vport->stats_lock); | 147 | spin_lock_init(&vport->stats_lock); |
156 | 148 | ||
157 | return vport; | 149 | return vport; |