locking/lockdep: Only call init_rcu_head() after RCU has been initialized
authorBart Van Assche <[email protected]>
Sun, 3 Mar 2019 18:19:01 +0000 (10:19 -0800)
committerIngo Molnar <[email protected]>
Sat, 9 Mar 2019 13:15:51 +0000 (14:15 +0100)
init_data_structures_once() is called for the first time before RCU has
been initialized. Make sure that init_rcu_head() is called before the
RCU head is used and after RCU has been initialized.

Signed-off-by: Bart Van Assche <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
kernel/locking/lockdep.c

index 35a144dfddf5b0d4f14fb2e5aeb42146711ec68c..34cdcbedda492b84cb610af67cb11113ea04065d 100644 (file)
@@ -982,15 +982,22 @@ static inline void check_data_structures(void) { }
  */
 static void init_data_structures_once(void)
 {
-       static bool initialization_happened;
+       static bool ds_initialized, rcu_head_initialized;
        int i;
 
-       if (likely(initialization_happened))
+       if (likely(rcu_head_initialized))
                return;
 
-       initialization_happened = true;
+       if (system_state >= SYSTEM_SCHEDULING) {
+               init_rcu_head(&delayed_free.rcu_head);
+               rcu_head_initialized = true;
+       }
+
+       if (ds_initialized)
+               return;
+
+       ds_initialized = true;
 
-       init_rcu_head(&delayed_free.rcu_head);
        INIT_LIST_HEAD(&delayed_free.pf[0].zapped);
        INIT_LIST_HEAD(&delayed_free.pf[1].zapped);