Thread (31 messages) 31 messages, 6 authors, 2021-02-03

Re: [PATCH 04/13] module: use RCU to synchronize find_module

From: Miroslav Benes <mbenes@suse.cz>
Date: 2021-01-29 15:30:52

On Thu, 28 Jan 2021, Christoph Hellwig wrote:
Allow for a RCU-sched critical section around find_module, following
the lower level find_module_all helper, and switch the two callers
outside of module.c to use such a RCU-sched critical section instead
of module_mutex.
That's a nice idea.
 
quoted hunk ↗ jump to hunk
@@ -57,7 +58,7 @@ static void klp_find_object_module(struct klp_object *obj)
 	if (!klp_is_module(obj))
 		return;
 
-	mutex_lock(&module_mutex);
+	rcu_read_lock_sched();
 	/*
 	 * We do not want to block removal of patched modules and therefore
 	 * we do not take a reference here. The patches are removed by
@@ -74,7 +75,7 @@ static void klp_find_object_module(struct klp_object *obj)
 	if (mod && mod->klp_alive)
RCU always baffles me a bit, so I'll ask. Don't we need 
rcu_dereference_sched() here? "mod" comes from a RCU-protected list, so I 
wonder.
 		obj->mod = mod;
 
-	mutex_unlock(&module_mutex);
+	rcu_read_unlock_sched();
 }
Thanks

Miroslav
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help