net: Explicitly initialize u64_stats_sync structures for lockdep
authorJohn Stultz <john.stultz@linaro.org>
Mon, 7 Oct 2013 22:51:58 +0000 (15:51 -0700)
committerDanny Wood <danwood76@gmail.com>
Thu, 15 Jul 2021 09:45:32 +0000 (10:45 +0100)
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>
Change-Id: If41808d130a6c0235faf7c64f17c7beaf33d40ae

33 files changed:
drivers/net/dummy.c
drivers/net/ethernet/emulex/benet/be_main.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/marvell/sky2.c
drivers/net/ethernet/neterion/vxge/vxge-main.c
drivers/net/ethernet/nvidia/forcedeth.c
drivers/net/ethernet/realtek/8139too.c
drivers/net/ethernet/tile/tilepro.c
drivers/net/ethernet/via/via-rhine.c
drivers/net/ifb.c
drivers/net/loopback.c
drivers/net/macvlan.c
drivers/net/team/team.c
drivers/net/team/team_mode_loadbalance.c
drivers/net/veth.c
drivers/net/virtio_net.c
drivers/net/vxlan.c
drivers/net/xen-netfront.c
include/linux/u64_stats_sync.h
net/8021q/vlan_dev.c
net/bridge/br_device.c
net/ipv4/af_inet.c
net/ipv4/ip_tunnel.c
net/ipv6/addrconf.c
net/ipv6/af_inet6.c
net/ipv6/ip6_gre.c
net/ipv6/ip6_tunnel.c
net/ipv6/sit.c
net/netfilter/ipvs/ip_vs_ctl.c
net/openvswitch/datapath.c
net/openvswitch/vport.c

index b710c6b2d65962db616017a6572cf75e425d69a1..bd8f84b0b894ebfe616a85b365598347d648200f 100644 (file)
@@ -88,10 +88,16 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
 
 static int dummy_dev_init(struct net_device *dev)
 {
+       int i;
        dev->dstats = alloc_percpu(struct pcpu_dstats);
        if (!dev->dstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_dstats *dstats;
+               dstats = per_cpu_ptr(dev->dstats, i);
+               u64_stats_init(&dstats->syncp);
+       }
        return 0;
 }
 
index 88e85cb88342cea8a5810412df04de3a9a488141..a2729129f4c347843cd172741e71c1cd6cc85b4d 100644 (file)
@@ -2051,6 +2051,9 @@ static int be_tx_cqs_create(struct be_adapter *adapter)
                if (status)
                        return status;
 
+               u64_stats_init(&txo->stats.sync);
+               u64_stats_init(&txo->stats.sync_compl);
+
                /* If num_evt_qs is less than num_tx_qs, then more than
                 * one txq share an eq
                 */
@@ -2124,6 +2127,7 @@ static int be_rx_cqs_create(struct be_adapter *adapter)
                if (rc)
                        return rc;
 
+               u64_stats_init(&rxo->stats.sync);
                eq = &adapter->eq_obj[i % adapter->num_evt_qs].q;
                rc = be_cmd_cq_create(adapter, cq, eq, false, 3);
                if (rc)
index 3f342fbe9ccfeb0cc3460b2cdc0ccf5f764d6eb9..b17a590aee699b6605d452e028068a7744c78167 100644 (file)
@@ -1221,6 +1221,9 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,
                ring->count = adapter->tx_ring_count;
                ring->queue_index = txr_idx;
 
+               u64_stats_init(&ring->tx_syncp);
+               u64_stats_init(&ring->tx_syncp2);
+
                /* assign ring to adapter */
                adapter->tx_ring[txr_idx] = ring;
 
@@ -1254,6 +1257,8 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,
                ring->count = adapter->rx_ring_count;
                ring->queue_index = rxr_idx;
 
+               u64_stats_init(&ring->rx_syncp);
+
                /* assign ring to adapter */
                adapter->rx_ring[rxr_idx] = ring;
        }
index c2936661fbcbf728c155f1eade276511b9957c7b..c590802671b1dfb7cab1df42df18b78c2372ceb3 100644 (file)
@@ -4719,6 +4719,8 @@ int ixgbe_setup_tx_resources(struct ixgbe_ring *tx_ring)
        if (!tx_ring->tx_buffer_info)
                goto err;
 
+       u64_stats_init(&tx_ring->syncp);
+
        /* round up to nearest 4K */
        tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);
        tx_ring->size = ALIGN(tx_ring->size, 4096);
@@ -4801,6 +4803,8 @@ int ixgbe_setup_rx_resources(struct ixgbe_ring *rx_ring)
        if (!rx_ring->rx_buffer_info)
                goto err;
 
+       u64_stats_init(&rx_ring->syncp);
+
        /* Round up to nearest 4K */
        rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
        rx_ring->size = ALIGN(rx_ring->size, 4096);
index df3af299a7d2d576783af6931ce2d13b74f17d8f..230781cddad892d6d07c1ad08ddf25a26b22f281 100644 (file)
@@ -2735,6 +2735,9 @@ static int mvneta_probe(struct platform_device *pdev)
 
        pp = netdev_priv(dev);
 
+       u64_stats_init(&pp->tx_stats.syncp);
+       u64_stats_init(&pp->rx_stats.syncp);
+
        pp->weight = MVNETA_RX_POLL_WEIGHT;
        pp->phy_node = phy_node;
        pp->phy_interface = phy_mode;
index 4ac9dfd3f127b96570006ab892be18cc4a0c8f5c..093cb077aede350b130bd4f1d6b13c7e5e75b79a 100644 (file)
@@ -4763,6 +4763,9 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
        sky2->hw = hw;
        sky2->msg_enable = netif_msg_init(debug, default_msg);
 
+       u64_stats_init(&sky2->tx_stats.syncp);
+       u64_stats_init(&sky2->rx_stats.syncp);
+
        /* Auto speed and flow control */
        sky2->flags = SKY2_FLAG_AUTO_SPEED | SKY2_FLAG_AUTO_PAUSE;
        if (hw->chip_id != CHIP_ID_YUKON_XL)
index cbfaed5f2f8df2617a45f7f08150492c398104fa..709f85729e6a9c793fa20f76d3407fd8dd8906a8 100644 (file)
@@ -2072,6 +2072,10 @@ static int vxge_open_vpaths(struct vxgedev *vdev)
                                vdev->config.tx_steering_type;
                        vpath->fifo.ndev = vdev->ndev;
                        vpath->fifo.pdev = vdev->pdev;
+
+                       u64_stats_init(&vpath->fifo.stats.syncp);
+                       u64_stats_init(&vpath->ring.stats.syncp);
+
                        if (vdev->config.tx_steering_type)
                                vpath->fifo.txq =
                                        netdev_get_tx_queue(vdev->ndev, i);
index b003fe53c8e2508e3de8f2c2a118060b57ac02ac..2219b05f91b9ac625fadbd408fe4f125aba5f6d2 100644 (file)
@@ -5619,6 +5619,8 @@ static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
        spin_lock_init(&np->lock);
        spin_lock_init(&np->hwstats_lock);
        SET_NETDEV_DEV(dev, &pci_dev->dev);
+       u64_stats_init(&np->swstats_rx_syncp);
+       u64_stats_init(&np->swstats_tx_syncp);
 
        init_timer(&np->oom_kick);
        np->oom_kick.data = (unsigned long) dev;
index 942673fcb391f491d91269db284d0ab6537a7523..7caa4fb770d3fc992a6d9f0983d9b5a614eb7f0c 100644 (file)
@@ -791,6 +791,9 @@ static struct net_device *rtl8139_init_board(struct pci_dev *pdev)
 
        pci_set_master (pdev);
 
+       u64_stats_init(&tp->rx_stats.syncp);
+       u64_stats_init(&tp->tx_stats.syncp);
+
 retry:
        /* PIO bar register comes first. */
        bar = !use_io;
index 36435499814b78d34020503caa41fdb00d2cd57f..364c5544efe8dce42d8b83f3bb31887c0568e538 100644 (file)
@@ -1093,6 +1093,8 @@ static void tile_net_register(void *dev_ptr)
        info->egress_timer.data = (long)info;
        info->egress_timer.function = tile_net_handle_egress_timer;
 
+       u64_stats_init(&info->stats.syncp);
+
        priv->cpu[my_cpu] = info;
 
        /*
index c879969e82fbf274a6ff9ea1f2e46ae76466c6f6..9ea57eb66aa41569df09b12a649e54b6879ca60c 100644 (file)
@@ -987,6 +987,9 @@ static int rhine_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        rp->base = ioaddr;
 
+       u64_stats_init(&rp->tx_stats.syncp);
+       u64_stats_init(&rp->rx_stats.syncp);
+
        /* Get chip registers into a sane state */
        rhine_power_init(dev);
        rhine_hw_init(dev, pioaddr);
index a3bed28197d29bf9722b6c586f311827d357b501..c14d39bf32d06a6f8d1b42a29b36dcd84b25c8f6 100644 (file)
@@ -265,6 +265,7 @@ MODULE_PARM_DESC(numifbs, "Number of ifb devices");
 static int __init ifb_init_one(int index)
 {
        struct net_device *dev_ifb;
+       struct ifb_private *dp;
        int err;
 
        dev_ifb = alloc_netdev(sizeof(struct ifb_private),
@@ -273,6 +274,10 @@ static int __init ifb_init_one(int index)
        if (!dev_ifb)
                return -ENOMEM;
 
+       dp = netdev_priv(dev_ifb);
+       u64_stats_init(&dp->rsync);
+       u64_stats_init(&dp->tsync);
+
        dev_ifb->rtnl_link_ops = &ifb_link_ops;
        err = register_netdevice(dev_ifb);
        if (err < 0)
index fcbf680c3e62f73af4933896641045de34f1f68c..d7e0c5a60b4cafceb2572e175a782bc15e590585 100644 (file)
@@ -137,10 +137,16 @@ static const struct ethtool_ops loopback_ethtool_ops = {
 
 static int loopback_dev_init(struct net_device *dev)
 {
+       int i;
        dev->lstats = alloc_percpu(struct pcpu_lstats);
        if (!dev->lstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_lstats *lb_stats;
+               lb_stats = per_cpu_ptr(dev->lstats, i);
+               u64_stats_init(&lb_stats->syncp);
+       }
        return 0;
 }
 
index 9be91cb4f4a305c64996ab6e4aeb31d94af547b6..299af98d7b69060f1632bca92f6857b9208ee5f4 100644 (file)
@@ -495,6 +495,7 @@ static int macvlan_init(struct net_device *dev)
 {
        struct macvlan_dev *vlan = netdev_priv(dev);
        const struct net_device *lowerdev = vlan->lowerdev;
+       int i;
 
        dev->state              = (dev->state & ~MACVLAN_STATE_MASK) |
                                  (lowerdev->state & MACVLAN_STATE_MASK);
@@ -511,6 +512,12 @@ static int macvlan_init(struct net_device *dev)
        if (!vlan->pcpu_stats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct macvlan_pcpu_stats *mvlstats;
+               mvlstats = per_cpu_ptr(vlan->pcpu_stats, i);
+               u64_stats_init(&mvlstats->syncp);
+       }
+
        return 0;
 }
 
index 0a3ad7ba2bea4b81af240810cbb3b06c50496628..c168f334f928ffa64a3d4ed22ea3f2120855ee0f 100644 (file)
@@ -1367,6 +1367,12 @@ static int team_init(struct net_device *dev)
        if (!team->pcpu_stats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct team_pcpu_stats *team_stats;
+               team_stats = per_cpu_ptr(team->pcpu_stats, i);
+               u64_stats_init(&team_stats->syncp);
+       }
+
        for (i = 0; i < TEAM_PORT_HASHENTRIES; i++)
                INIT_HLIST_HEAD(&team->en_port_hlist[i]);
        INIT_LIST_HEAD(&team->port_list);
index cdc31b5ea15eb21325b4fc1d3619288a0300e357..cd874ccb8b23ebbc4491c626c8402482eab12a9f 100644 (file)
@@ -571,7 +571,7 @@ static int lb_init(struct team *team)
 {
        struct lb_priv *lb_priv = get_lb_priv(team);
        lb_select_tx_port_func_t *func;
-       int err;
+       int i, err;
 
        /* set default tx port selector */
        func = lb_select_tx_port_get_func("hash");
@@ -589,6 +589,13 @@ static int lb_init(struct team *team)
                goto err_alloc_pcpu_stats;
        }
 
+       for_each_possible_cpu(i) {
+               struct lb_pcpu_stats *team_lb_stats;
+               team_lb_stats = per_cpu_ptr(lb_priv->pcpu_stats, i);
+               u64_stats_init(&team_lb_stats->syncp);
+       }
+
+
        INIT_DELAYED_WORK(&lb_priv->ex->stats.refresh_dw, lb_stats_refresh);
 
        err = team_options_register(team, lb_options, ARRAY_SIZE(lb_options));
index cc6d3f98743693d85b0a50565782e2d8bdcb275e..689393179757c5be1f2d6adc9c8483ef4505dc9d 100644 (file)
@@ -224,10 +224,18 @@ static int veth_change_mtu(struct net_device *dev, int new_mtu)
 
 static int veth_dev_init(struct net_device *dev)
 {
+       int i;
+
        dev->vstats = alloc_percpu(struct pcpu_vstats);
        if (!dev->vstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_vstats *veth_stats;
+               veth_stats = per_cpu_ptr(dev->vstats, i);
+               u64_stats_init(&veth_stats->syncp);
+       }
+
        return 0;
 }
 
index b5d11529a39b01024a2e83c2026f5139228a729c..415a576c0c2d165a3c8c24cee395bf935786d44b 100644 (file)
@@ -1586,6 +1586,14 @@ static int virtnet_probe(struct virtio_device *vdev)
        if (vi->stats == NULL)
                goto free;
 
+       for_each_possible_cpu(i) {
+               struct virtnet_stats *virtnet_stats;
+               virtnet_stats = per_cpu_ptr(vi->stats, i);
+               u64_stats_init(&virtnet_stats->tx_syncp);
+               u64_stats_init(&virtnet_stats->rx_syncp);
+       }
+
+
        vi->vq_index = alloc_percpu(int);
        if (vi->vq_index == NULL)
                goto free_stats;
index 8912ba83fd77f9e7d067f55e8cd7bb282d0ee336..5d449f0559664dff0b295b5eb87183c43805756d 100644 (file)
@@ -1217,10 +1217,18 @@ static void vxlan_cleanup(unsigned long arg)
 /* Setup stats when device is created */
 static int vxlan_init(struct net_device *dev)
 {
+       int i;
+
        dev->tstats = alloc_percpu(struct pcpu_tstats);
        if (!dev->tstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *vxlan_stats;
+               vxlan_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&vxlan_stats->syncp);
+       }
+
        return 0;
 }
 
index a1db958df4a4b6f517599ecb123dffcd283dae9d..9a2b6fd55cfd0def0295997e86f3ce18ad1dd2b4 100644 (file)
@@ -1280,6 +1280,12 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
        if (np->stats == NULL)
                goto exit;
 
+       for_each_possible_cpu(i) {
+               struct netfront_stats *xen_nf_stats;
+               xen_nf_stats = per_cpu_ptr(np->stats, i);
+               u64_stats_init(&xen_nf_stats->syncp);
+       }
+
        /* Initialise tx_skbs as a free chain containing every entry. */
        np->tx_skb_freelist = 0;
        for (i = 0; i < NET_TX_RING_SIZE; i++) {
index 8da8c4e87da3018323177000d46a5e42b19bf23f..7bfabd20204c150afa40a7249932519c0e770267 100644 (file)
@@ -67,6 +67,13 @@ struct u64_stats_sync {
 #endif
 };
 
+
+#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
+# define u64_stats_init(syncp) seqcount_init(syncp.seq)
+#else
+# define u64_stats_init(syncp) do { } while (0)
+#endif
+
 static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
 {
 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
index 698e922f41ea154fff497150da46b4b2543d7aa3..65b84096c51f0d9ec6ffc067a6d1b7f2bee6c71e 100644 (file)
@@ -616,7 +616,7 @@ static const struct net_device_ops vlan_netdev_ops;
 static int vlan_dev_init(struct net_device *dev)
 {
        struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
-       int subclass = 0;
+       int subclass = 0, i;
 
        netif_carrier_off(dev);
 
@@ -669,6 +669,13 @@ static int vlan_dev_init(struct net_device *dev)
        if (!vlan_dev_priv(dev)->vlan_pcpu_stats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct vlan_pcpu_stats *vlan_stat;
+               vlan_stat = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
+               u64_stats_init(&vlan_stat->syncp);
+       }
+
+
        return 0;
 }
 
index 239e0e84f9e6eef6ff5c17f8e6477d8663974aae..0b99e00652278c6c59dac0190071a2089164ba8b 100644 (file)
@@ -85,11 +85,18 @@ out:
 static int br_dev_init(struct net_device *dev)
 {
        struct net_bridge *br = netdev_priv(dev);
+       int i;
 
        br->stats = alloc_percpu(struct br_cpu_netstats);
        if (!br->stats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct br_cpu_netstats *br_dev_stats;
+               br_dev_stats = per_cpu_ptr(br->stats, i);
+               u64_stats_init(&br_dev_stats->syncp);
+       }
+
        return 0;
 }
 
index 87725f3c2f0484dd94c3d9ff4bae38ec30c75368..0d54481ba1934a2e5a7730d12f037b4919ea06bd 100644 (file)
@@ -1538,6 +1538,7 @@ int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align)
        ptr[0] = __alloc_percpu(mibsize, align);
        if (!ptr[0])
                return -ENOMEM;
+
 #if SNMP_ARRAY_SZ == 2
        ptr[1] = __alloc_percpu(mibsize, align);
        if (!ptr[1]) {
@@ -1609,6 +1610,8 @@ static const struct net_protocol icmp_protocol = {
 
 static __net_init int ipv4_mib_init_net(struct net *net)
 {
+       int i;
+
        if (snmp_mib_init((void __percpu **)net->mib.tcp_statistics,
                          sizeof(struct tcp_mib),
                          __alignof__(struct tcp_mib)) < 0)
@@ -1617,6 +1620,17 @@ static __net_init int ipv4_mib_init_net(struct net *net)
                          sizeof(struct ipstats_mib),
                          __alignof__(struct ipstats_mib)) < 0)
                goto err_ip_mib;
+
+       for_each_possible_cpu(i) {
+               struct ipstats_mib *af_inet_stats;
+               af_inet_stats = per_cpu_ptr(net->mib.ip_statistics[0], i);
+               u64_stats_init(&af_inet_stats->syncp);
+#if SNMP_ARRAY_SZ == 2
+               af_inet_stats = per_cpu_ptr(net->mib.ip_statistics[1], i);
+               u64_stats_init(&af_inet_stats->syncp);
+#endif
+       }
+
        if (snmp_mib_init((void __percpu **)net->mib.net_statistics,
                          sizeof(struct linux_mib),
                          __alignof__(struct linux_mib)) < 0)
index 84aa69caee59486e3dffa0e0c8447a0c278ab0ed..1dd6ec0d3a78e0211072e29eea446e808bf336ec 100644 (file)
@@ -1005,13 +1005,19 @@ int ip_tunnel_init(struct net_device *dev)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
        struct iphdr *iph = &tunnel->parms.iph;
-       int err;
+       int i, err;
 
        dev->destructor = ip_tunnel_dev_free;
        dev->tstats = alloc_percpu(struct pcpu_tstats);
        if (!dev->tstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *ipt_stats;
+               ipt_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&ipt_stats->syncp);
+       }
+
        err = gro_cells_init(&tunnel->gro_cells, dev);
        if (err) {
                free_percpu(dev->tstats);
index f52cdb0e296b84a99c87a2204ba8bf6ab7ecda16..f635622046454497135a7314a23a19fe149b144e 100644 (file)
@@ -287,10 +287,24 @@ static void addrconf_mod_dad_work(struct inet6_ifaddr *ifp,
 
 static int snmp6_alloc_dev(struct inet6_dev *idev)
 {
+       int i;
+
        if (snmp_mib_init((void __percpu **)idev->stats.ipv6,
                          sizeof(struct ipstats_mib),
                          __alignof__(struct ipstats_mib)) < 0)
                goto err_ip;
+
+       for_each_possible_cpu(i) {
+               struct ipstats_mib *addrconf_stats;
+               addrconf_stats = per_cpu_ptr(idev->stats.ipv6[0], i);
+               u64_stats_init(&addrconf_stats->syncp);
+#if SNMP_ARRAY_SZ == 2
+               addrconf_stats = per_cpu_ptr(idev->stats.ipv6[1], i);
+               u64_stats_init(&addrconf_stats->syncp);
+#endif
+       }
+
+
        idev->stats.icmpv6dev = kzalloc(sizeof(struct icmpv6_mib_device),
                                        GFP_KERNEL);
        if (!idev->stats.icmpv6dev)
index db3b20e10c65149d738958cec93624a032b31009..f08c9f5aeec873218917c2fc22f1d0bf931bf2c7 100644 (file)
@@ -763,6 +763,8 @@ static void ipv6_packet_cleanup(void)
 
 static int __net_init ipv6_init_mibs(struct net *net)
 {
+       int i;
+
        if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6,
                          sizeof(struct udp_mib),
                          __alignof__(struct udp_mib)) < 0)
@@ -775,6 +777,18 @@ static int __net_init ipv6_init_mibs(struct net *net)
                          sizeof(struct ipstats_mib),
                          __alignof__(struct ipstats_mib)) < 0)
                goto err_ip_mib;
+
+       for_each_possible_cpu(i) {
+               struct ipstats_mib *af_inet6_stats;
+               af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics[0], i);
+               u64_stats_init(&af_inet6_stats->syncp);
+#if SNMP_ARRAY_SZ == 2
+               af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics[1], i);
+               u64_stats_init(&af_inet6_stats->syncp);
+#endif
+       }
+
+
        if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics,
                          sizeof(struct icmpv6_mib),
                          __alignof__(struct icmpv6_mib)) < 0)
index 70453acb83852a1fa0c275df693df06781a1711b..3965b1491929ab99620584f03ef5497996c965b5 100644 (file)
@@ -1256,6 +1256,7 @@ static void ip6gre_tunnel_setup(struct net_device *dev)
 static int ip6gre_tunnel_init(struct net_device *dev)
 {
        struct ip6_tnl *tunnel;
+       int i;
 
        tunnel = netdev_priv(dev);
 
@@ -1272,6 +1273,12 @@ static int ip6gre_tunnel_init(struct net_device *dev)
        if (!dev->tstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *ip6gre_tunnel_stats;
+               ip6gre_tunnel_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&ip6gre_tunnel_stats->syncp);
+       }
+
        dev->iflink = tunnel->parms.link;
 
        return 0;
@@ -1452,6 +1459,7 @@ static void ip6gre_netlink_parms(struct nlattr *data[],
 static int ip6gre_tap_init(struct net_device *dev)
 {
        struct ip6_tnl *tunnel;
+       int i;
 
        tunnel = netdev_priv(dev);
 
@@ -1464,6 +1472,12 @@ static int ip6gre_tap_init(struct net_device *dev)
        if (!dev->tstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *ip6gre_tap_stats;
+               ip6gre_tap_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&ip6gre_tap_stats->syncp);
+       }
+
        dev->iflink = tunnel->parms.link;
 
        return 0;
index cd0a8bed1ea47d82b7e75bd252258beafdb7ad44..e964106c2e33da38b295c88ddac95fd2095a0f0d 100644 (file)
@@ -1509,11 +1509,18 @@ static inline int
 ip6_tnl_dev_init_gen(struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
+       int i;
 
        t->dev = dev;
        dev->tstats = alloc_percpu(struct pcpu_tstats);
        if (!dev->tstats)
                return -ENOMEM;
+
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *ip6_tnl_stats;
+               ip6_tnl_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&ip6_tnl_stats->syncp);
+       }
        return 0;
 }
 
index d9535bb8fe2e0fd49563c6dddca5add00a238731..89d501db67117522175a8b239d6e908a438d95f1 100644 (file)
@@ -1249,6 +1249,7 @@ static void ipip6_tunnel_setup(struct net_device *dev)
 static int ipip6_tunnel_init(struct net_device *dev)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
+       int i;
 
        tunnel->dev = dev;
 
@@ -1260,6 +1261,12 @@ static int ipip6_tunnel_init(struct net_device *dev)
        if (!dev->tstats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *ipip6_tunnel_stats;
+               ipip6_tunnel_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&ipip6_tunnel_stats->syncp);
+       }
+
        return 0;
 }
 
@@ -1269,6 +1276,7 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
        struct iphdr *iph = &tunnel->parms.iph;
        struct net *net = dev_net(dev);
        struct sit_net *sitn = net_generic(net, sit_net_id);
+       int i;
 
        tunnel->dev = dev;
        strcpy(tunnel->parms.name, dev->name);
@@ -1281,6 +1289,13 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
        dev->tstats = alloc_percpu(struct pcpu_tstats);
        if (!dev->tstats)
                return -ENOMEM;
+
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *ipip6_fb_stats;
+               ipip6_fb_stats = per_cpu_ptr(dev->tstats, i);
+               u64_stats_init(&ipip6_fb_stats->syncp);
+       }
+
        dev_hold(dev);
        rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
        return 0;
index 9e6c2a075a4c9954c841556fb69f9e2523ddd894..c046240ea0350d0e3f25f41ea40a625598717d5f 100644 (file)
@@ -836,7 +836,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
               struct ip_vs_dest **dest_p)
 {
        struct ip_vs_dest *dest;
-       unsigned int atype;
+       unsigned int atype, i;
 
        EnterFunction(2);
 
@@ -863,6 +863,12 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
        if (!dest->stats.cpustats)
                goto err_alloc;
 
+       for_each_possible_cpu(i) {
+               struct ip_vs_cpu_stats *ip_vs_dest_stats;
+               ip_vs_dest_stats = per_cpu_ptr(dest->stats.cpustats, i);
+               u64_stats_init(&ip_vs_dest_stats->syncp);
+       }
+
        dest->af = svc->af;
        dest->protocol = svc->protocol;
        dest->vaddr = svc->addr;
@@ -1136,7 +1142,7 @@ static int
 ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u,
                  struct ip_vs_service **svc_p)
 {
-       int ret = 0;
+       int ret = 0, i;
        struct ip_vs_scheduler *sched = NULL;
        struct ip_vs_pe *pe = NULL;
        struct ip_vs_service *svc = NULL;
@@ -1186,6 +1192,13 @@ ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u,
                goto out_err;
        }
 
+       for_each_possible_cpu(i) {
+               struct ip_vs_cpu_stats *ip_vs_stats;
+               ip_vs_stats = per_cpu_ptr(svc->stats.cpustats, i);
+               u64_stats_init(&ip_vs_stats->syncp);
+       }
+
+
        /* I'm the first user of the service */
        atomic_set(&svc->refcnt, 0);
 
@@ -3775,7 +3788,7 @@ static struct notifier_block ip_vs_dst_notifier = {
 
 int __net_init ip_vs_control_net_init(struct net *net)
 {
-       int idx;
+       int i, idx;
        struct netns_ipvs *ipvs = net_ipvs(net);
 
        /* Initialize rs_table */
@@ -3794,6 +3807,12 @@ int __net_init ip_vs_control_net_init(struct net *net)
        if (!ipvs->tot_stats.cpustats)
                return -ENOMEM;
 
+       for_each_possible_cpu(i) {
+               struct ip_vs_cpu_stats *ipvs_tot_stats;
+               ipvs_tot_stats = per_cpu_ptr(ipvs->tot_stats.cpustats, i);
+               u64_stats_init(&ipvs_tot_stats->syncp);
+       }
+
        spin_lock_init(&ipvs->tot_stats.lock);
 
        proc_create("ip_vs", 0, net->proc_net, &ip_vs_info_fops);
index d12d6b8b5e8b1e4cd7d0f6504882fb47a866c52c..0efb131c5410d2dded75ff5f3b60a106b1c5d22e 100644 (file)
@@ -1395,6 +1395,12 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
                goto err_destroy_table;
        }
 
+       for_each_possible_cpu(i) {
+               struct dp_stats_percpu *dpath_stats;
+               dpath_stats = per_cpu_ptr(dp->stats_percpu, i);
+               u64_stats_init(&dpath_stats->sync);
+       }
+
        dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
                        GFP_KERNEL);
        if (!dp->ports) {
index 720623190eaa82d9ad4a2fcf460a0270cf57a03b..be666f956f81016835679cc0164cffdae13521ec 100644 (file)
@@ -111,6 +111,7 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
 {
        struct vport *vport;
        size_t alloc_size;
+       int i;
 
        alloc_size = sizeof(struct vport);
        if (priv_size) {
@@ -134,6 +135,13 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
                return ERR_PTR(-ENOMEM);
        }
 
+       for_each_possible_cpu(i) {
+               struct pcpu_tstats *vport_stats;
+               vport_stats = per_cpu_ptr(vport->percpu_stats, i);
+               u64_stats_init(&vport_stats->syncp);
+       }
+
+
        spin_lock_init(&vport->stats_lock);
 
        return vport;