]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.10/u64_stats-fix-u64_stats_init-for-lockdep-when-used-r.patch
drop some 5.10 patches
[thirdparty/kernel/stable-queue.git] / queue-5.10 / u64_stats-fix-u64_stats_init-for-lockdep-when-used-r.patch
CommitLineData
e5703824 1From 57a453fd0d2c0878818807a76fda9f9fa4353f32 Mon Sep 17 00:00:00 2001
7f87a3cd
SL
2From: Sasha Levin <sashal@kernel.org>
3Date: Thu, 4 Apr 2024 09:57:40 +0200
4Subject: u64_stats: fix u64_stats_init() for lockdep when used repeatedly in
5 one file
6
7From: Petr Tesarik <petr@tesarici.cz>
8
9[ Upstream commit 38a15d0a50e0a43778561a5861403851f0b0194c ]
10
11Fix bogus lockdep warnings if multiple u64_stats_sync variables are
12initialized in the same file.
13
14With CONFIG_LOCKDEP, seqcount_init() is a macro which declares:
15
16 static struct lock_class_key __key;
17
18Since u64_stats_init() is a function (albeit an inline one), all calls
19within the same file end up using the same instance, effectively treating
20them all as a single lock-class.
21
22Fixes: 9464ca650008 ("net: make u64_stats_init() a function")
23Closes: https://lore.kernel.org/netdev/ea1567d9-ce66-45e6-8168-ac40a47d1821@roeck-us.net/
24Signed-off-by: Petr Tesarik <petr@tesarici.cz>
25Reviewed-by: Simon Horman <horms@kernel.org>
26Reviewed-by: Eric Dumazet <edumazet@google.com>
27Link: https://lore.kernel.org/r/20240404075740.30682-1-petr@tesarici.cz
28Signed-off-by: Jakub Kicinski <kuba@kernel.org>
29Signed-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 {