Skip to content

Commit 38a15d0

Browse files
ptesarikkuba-moo
authored andcommitted
u64_stats: fix u64_stats_init() for lockdep when used repeatedly in one file
Fix bogus lockdep warnings if multiple u64_stats_sync variables are initialized in the same file. With CONFIG_LOCKDEP, seqcount_init() is a macro which declares: static struct lock_class_key __key; Since u64_stats_init() is a function (albeit an inline one), all calls within the same file end up using the same instance, effectively treating them all as a single lock-class. Fixes: 9464ca6 ("net: make u64_stats_init() a function") Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Petr Tesarik <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4539f91 commit 38a15d0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/linux/u64_stats_sync.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,11 @@ static inline void u64_stats_inc(u64_stats_t *p)
135135
p->v++;
136136
}
137137

138-
static inline void u64_stats_init(struct u64_stats_sync *syncp)
139-
{
140-
seqcount_init(&syncp->seq);
141-
}
138+
#define u64_stats_init(syncp) \
139+
do { \
140+
struct u64_stats_sync *__s = (syncp); \
141+
seqcount_init(&__s->seq); \
142+
} while (0)
142143

143144
static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp)
144145
{

0 commit comments

Comments
 (0)