aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/af_inet.c
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/ipv4/af_inet.c
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/ipv4/af_inet.c')
-rw-r--r--net/ipv4/af_inet.c14
1 files changed, 14 insertions, 0 deletions
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)