]> Git Repo - linux.git/commitdiff
u64_stats,lockdep: Fix u64_stats_init() vs lockdep
authorPeter Zijlstra <[email protected]>
Mon, 8 Mar 2021 08:38:12 +0000 (09:38 +0100)
committerPeter Zijlstra <[email protected]>
Wed, 10 Mar 2021 08:51:45 +0000 (09:51 +0100)
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]
include/linux/u64_stats_sync.h

index c6abb79501b33c7afbd00196dd3a5f644ae4da83..e81856c0ba134fd07401f3e0e562828f0c8f1333 100644 (file)
@@ -115,12 +115,13 @@ static inline void u64_stats_inc(u64_stats_t *p)
 }
 #endif
 
+#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
+#define u64_stats_init(syncp)  seqcount_init(&(syncp)->seq)
+#else
 static inline void u64_stats_init(struct u64_stats_sync *syncp)
 {
-#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
-       seqcount_init(&syncp->seq);
-#endif
 }
+#endif
 
 static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
 {
This page took 0.061249 seconds and 4 git commands to generate.