Subject: [PATCH 23/28] jump_label: Use RCU in all users of __module_address().
From: Sebastian Andrzej Siewior <[email-masked]>
Date: Wed, 8 Jan 2025 10:04:52 +0100

__module_address() can be invoked within a RCU section, there is no
requirement to have preemption disabled.

Replace the preempt_disable() section around __module_address() with RCU.

Cc: Ard Biesheuvel <[email-masked]>
Cc: Jason Baron <[email-masked]>
Cc: Josh Poimboeuf <[email-masked]>
Cc: Peter Zijlstra <[email-masked]>
Cc: Steven Rostedt <[email-masked]>
Acked-by: Peter Zijlstra (Intel) <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Signed-off-by: Sebastian Andrzej Siewior <[email-masked]>
---
 kernel/jump_label.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -746,9 +746,9 @@ static int jump_label_add_module(struct
 				kfree(jlm);
 				return -ENOMEM;
 			}
-			preempt_disable();
-			jlm2->mod = __module_address((unsigned long)key);
-			preempt_enable();
+			scoped_guard(rcu)
+				jlm2->mod = __module_address((unsigned long)key);
+
 			jlm2->entries = static_key_entries(key);
 			jlm2->next = NULL;
 			static_key_set_mod(key, jlm2);
@@ -906,13 +906,13 @@ static void jump_label_update(struct sta
 		return;
 	}
 
-	preempt_disable();
-	mod = __module_address((unsigned long)key);
-	if (mod) {
-		stop = mod->jump_entries + mod->num_jump_entries;
-		init = mod->state == MODULE_STATE_COMING;
+	scoped_guard(rcu) {
+		mod = __module_address((unsigned long)key);
+		if (mod) {
+			stop = mod->jump_entries + mod->num_jump_entries;
+			init = mod->state == MODULE_STATE_COMING;
+		}
 	}
-	preempt_enable();
 #endif
 	entry = static_key_entries(key);
 	/* if there are no users, entry can be NULL */