Skip to contentSkip to conversation

jump_label: invoke jump_label_test() via early_initcall()

PATCH In review Jason Baron 3 participants 3 messages Nov 13, 2017 – Nov 14, 2017 Static branch/call

lore
Share & tools
lore

Jason Baron

author maintainer
#0 lore raw

PATCH 1/1 jump_label: invoke jump_label_test() via early_initcall()

Fengguang Wu reported that running the rcuperf test during boot can cause the jump_label_test() to hit a WARN_ON(). The issue is that the core jump label code relies on kernel_text_address() to detect when it can no longer update branches that may be contained in __init sections. The kernel_text_address() in turn assumes that if the system_state variable is greter than or equal to SYSTEM_RUNNING then __init sections are no longer valid (since the assumption is that they have been freed). However, when rcuperf is setup to run in early boot it can call kernel_power_off() which sets the system_state to SYSTEM_POWER_OFF.

Since rcuperf initialization is invoked via a module_init(), we can make the dependency of jump_label_test() needing to complete before rcuperf explicit by calling it via early_initcall().

Cc "Paul E. McKenney" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/jump_label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/jump_label.c +1 -1
index 0bf2e8f5..7c3774a 100644
@@ -769,7 +769,7 @@ static __init int jump_label_test(void)
 
 	return 0;
 }
-late_initcall(jump_label_test);
+early_initcall(jump_label_test);
 #endif /* STATIC_KEYS_SELFTEST */
 
 #endif /* HAVE_JUMP_LABEL */
Signature · 1 line
2.6.1
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Jason Baron

Fengguang Wu reported that running the rcuperf test during boot can cause the jump_label_test() to hit a WARN_ON(). The issue is that the core jump label code relies on kernel_text_address() to detect when it can no longer update branches that may be contained in __init sections. The kernel_text_address() in turn assumes that if the system_state variable is greter than or equal to SYSTEM_RUNNING then __init sections are no longer valid (since the assumption is that they have been freed). However, when rcuperf is setup to run in early boot it can call kernel_power_off() which sets the system_state to SYSTEM_POWER_OFF.

Since rcuperf initialization is invoked via a module_init(), we can make the dependency of jump_label_test() needing to complete before rcuperf explicit by calling it via early_initcall().

Quoted 6 lines
Cc "Paul E. McKenney" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>

Looks way simpler than handling this three times in rcuperf, rcutorture, and locktorture!

Quoted 20 lines
---
 kernel/jump_label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/jump_label.c +1 -1
index 0bf2e8f5..7c3774a 100644
@@ -769,7 +769,7 @@ static __init int jump_label_test(void)
 
 	return 0;
 }
-late_initcall(jump_label_test);
+early_initcall(jump_label_test);
 #endif /* STATIC_KEYS_SELFTEST */
 
 #endif /* HAVE_JUMP_LABEL */
Signature · 1 line
2.6.1
#2 lore raw

[tip:locking/urgent] jump_label: Invoke jump_label_test() via early_initcall()

In reply to Jason Baron
jump_label: Invoke jump_label_test() via early_initcall()
Commit-ID:  92ee46efeb505ead3ab06d3c5ce695637ed5f152
Gitweb:     https://git.kernel.org/tip/92ee46efeb505ead3ab06d3c5ce695637ed5f152
Author:     Jason Baron <[email protected]>
AuthorDate: Mon, 13 Nov 2017 16:48:47 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 14 Nov 2017 08:41:41 +0100

jump_label: Invoke jump_label_test() via early_initcall()

Fengguang Wu reported that running the rcuperf test during boot can cause the jump_label_test() to hit a WARN_ON(). The issue is that the core jump label code relies on kernel_text_address() to detect when it can no longer update branches that may be contained in __init sections. The kernel_text_address() in turn assumes that if the system_state variable is greter than or equal to SYSTEM_RUNNING then __init sections are no longer valid (since the assumption is that they have been freed). However, when rcuperf is setup to run in early boot it can call kernel_power_off() which sets the system_state to SYSTEM_POWER_OFF.

Since rcuperf initialization is invoked via a module_init(), we can make the dependency of jump_label_test() needing to complete before rcuperf explicit by calling it via early_initcall().

---
 kernel/jump_label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/jump_label.c +1 -1
index 8ff4ca4..8594d24 100644
@@ -769,7 +769,7 @@ static __init int jump_label_test(void)
 
 	return 0;
 }
-late_initcall(jump_label_test);
+early_initcall(jump_label_test);
 #endif /* STATIC_KEYS_SELFTEST */
 
 #endif /* HAVE_JUMP_LABEL */