aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch
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/openvswitch
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/openvswitch')
-rw-r--r--net/openvswitch/datapath.c6
-rw-r--r--net/openvswitch/vport.c8
2 files changed, 14 insertions, 0 deletions
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;