]>
Commit | Line | Data |
---|---|---|
e5703824 | 1 | From 57a453fd0d2c0878818807a76fda9f9fa4353f32 Mon Sep 17 00:00:00 2001 |
7f87a3cd SL |
2 | From: Sasha Levin <sashal@kernel.org> |
3 | Date: Thu, 4 Apr 2024 09:57:40 +0200 | |
4 | Subject: u64_stats: fix u64_stats_init() for lockdep when used repeatedly in | |
5 | one file | |
6 | ||
7 | From: Petr Tesarik <petr@tesarici.cz> | |
8 | ||
9 | [ Upstream commit 38a15d0a50e0a43778561a5861403851f0b0194c ] | |
10 | ||
11 | Fix bogus lockdep warnings if multiple u64_stats_sync variables are | |
12 | initialized in the same file. | |
13 | ||
14 | With CONFIG_LOCKDEP, seqcount_init() is a macro which declares: | |
15 | ||
16 | static struct lock_class_key __key; | |
17 | ||
18 | Since u64_stats_init() is a function (albeit an inline one), all calls | |
19 | within the same file end up using the same instance, effectively treating | |
20 | them all as a single lock-class. | |
21 | ||
22 | Fixes: 9464ca650008 ("net: make u64_stats_init() a function") | |
23 | Closes: https://lore.kernel.org/netdev/ea1567d9-ce66-45e6-8168-ac40a47d1821@roeck-us.net/ | |
24 | Signed-off-by: Petr Tesarik <petr@tesarici.cz> | |
25 | Reviewed-by: Simon Horman <horms@kernel.org> | |
26 | Reviewed-by: Eric Dumazet <edumazet@google.com> | |
27 | Link: https://lore.kernel.org/r/20240404075740.30682-1-petr@tesarici.cz | |
28 | Signed-off-by: Jakub Kicinski <kuba@kernel.org> | |
29 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
30 | --- | |
e5703824 GKH |
31 | include/linux/u64_stats_sync.h | 6 +++++- |
32 | 1 file changed, 5 insertions(+), 1 deletion(-) | |
7f87a3cd | 33 | |
7f87a3cd SL |
34 | --- a/include/linux/u64_stats_sync.h |
35 | +++ b/include/linux/u64_stats_sync.h | |
e5703824 GKH |
36 | @@ -116,7 +116,11 @@ static inline void u64_stats_inc(u64_sta |
37 | #endif | |
7f87a3cd | 38 | |
e5703824 GKH |
39 | #if BITS_PER_LONG == 32 && defined(CONFIG_SMP) |
40 | -#define u64_stats_init(syncp) seqcount_init(&(syncp)->seq) | |
7f87a3cd SL |
41 | +#define u64_stats_init(syncp) \ |
42 | + do { \ | |
43 | + struct u64_stats_sync *__s = (syncp); \ | |
44 | + seqcount_init(&__s->seq); \ | |
45 | + } while (0) | |
e5703824 GKH |
46 | #else |
47 | static inline void u64_stats_init(struct u64_stats_sync *syncp) | |
7f87a3cd | 48 | { |