On Wed, Jan 05, 2022 at 11:40:40AM IST, Alexei Starovoitov wrote:
On Sun, Jan 02, 2022 at 09:51:06PM +0530, Kumar Kartikeya Dwivedi wrote:
quoted
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 33bb8ae4a804..b5b423de53ab 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6338,7 +6338,10 @@ struct module *btf_try_get_module(const struct btf *btf)
if (btf_mod->btf != btf)
continue;
- if (try_module_get(btf_mod->module))
+ /* We must only consider module whose __init routine has
+ * finished, hence use try_module_get_live.
+ */
+ if (try_module_get_live(btf_mod->module))
Instead of patch 1 refactoring for this very specific case can we do:
1.
if (try_module_get(btf_mod->module)) {
if (btf_mod->module->state != MODULE_STATE_LIVE)
module_put(btf_mod->module);
else
res = btf_mod->module;
2.
preempt_disable();
if (btf_mod->module->state == MODULE_STATE_LIVE &&
try_module_get(btf_mod->module)) ...
preempt_enable();
3. add
case MODULE_STATE_LIVE:
to btf_module_notify()
and have an extra flag in struct btf_module to say that it's ready?
I'm mainly concerned about:
-EXPORT_SYMBOL(try_module_get);
+EXPORT_SYMBOL(__try_module_get);
in the patch 1. Not that I care about out of tree modules,
but we shouldn't be breaking them without a reason.
Alright, we could also export try_module_get, but let's go with option 3.
--
Kartikeya