]> 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
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / queue-5.10 / u64_stats-fix-u64_stats_init-for-lockdep-when-used-r.patch
CommitLineData
7f87a3cd
SL
1From d126067245d71c1d4a831a86eedbc702a5c6480a Mon Sep 17 00:00:00 2001
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---
31 include/linux/u64_stats_sync.h | 9 +++++----
32 1 file changed, 5 insertions(+), 4 deletions(-)
33
34diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h
35index 51f2e16b9540b..11c3162dade3b 100644
36--- a/include/linux/u64_stats_sync.h
37+++ b/include/linux/u64_stats_sync.h
38@@ -125,10 +125,11 @@ static inline void u64_stats_inc(u64_stats_t *p)
39 p->v++;
40 }
41
42-static inline void u64_stats_init(struct u64_stats_sync *syncp)
43-{
44- seqcount_init(&syncp->seq);
45-}
46+#define u64_stats_init(syncp) \
47+ do { \
48+ struct u64_stats_sync *__s = (syncp); \
49+ seqcount_init(&__s->seq); \
50+ } while (0)
51
52 static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp)
53 {
54--
552.43.0
56