Skip to content

Commit d5b0e06

Browse files
author
Peter Zijlstra
committed
u64_stats,lockdep: Fix u64_stats_init() vs lockdep
Jakub reported that: static struct net_device *rtl8139_init_board(struct pci_dev *pdev) { ... u64_stats_init(&tp->rx_stats.syncp); u64_stats_init(&tp->tx_stats.syncp); ... } results in lockdep getting confused between the RX and TX stats lock. This is because u64_stats_init() is an inline calling seqcount_init(), which is a macro using a static variable to generate a lockdep class. By wrapping that in an inline, we negate the effect of the macro and fold the static key variable, hence the confusion. Fix by also making u64_stats_init() a macro for the case where it matters, leaving the other case an inline for argument validation etc. Reported-by: Jakub Kicinski <[email protected]> Debugged-by: "Ahmed S. Darwish" <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: "Erhard F." <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 50bf808 commit d5b0e06

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/linux/u64_stats_sync.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ static inline void u64_stats_inc(u64_stats_t *p)
115115
}
116116
#endif
117117

118+
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
119+
#define u64_stats_init(syncp) seqcount_init(&(syncp)->seq)
120+
#else
118121
static inline void u64_stats_init(struct u64_stats_sync *syncp)
119122
{
120-
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
121-
seqcount_init(&syncp->seq);
122-
#endif
123123
}
124+
#endif
124125

125126
static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
126127
{

0 commit comments

Comments
 (0)