[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <8d7aa8b1-73a2-db7a-82c8-06917eddf235@huawei.com>
Date: Fri, 28 Jun 2019 20:32:18 +0800
From: Zhiqiang Liu <liuzhiqiang26@...wei.com>
To: <jeyu@...nel.org>, <rusty@...tcorp.com.au>, <kay.sievers@...y.org>,
<clabbe.montjoie@...il.com>
CC: <linux-kernel@...r.kernel.org>,
"wangxiaogang (F)" <wangxiaogang3@...wei.com>,
"Zhoukang (A)" <zhoukang7@...wei.com>,
Mingfangsen <mingfangsen@...wei.com>
Subject: [PATCH] module: add usage links when calling ref_module func
From: Zhiqiang Liu <liuzhiqiang26@...wei.com>
Problem: Users can call ref_module func in their modules to construct
relationships with other modules. However, the holders
'/sys/module/<mod-name>/holders' of the target module donot include
the users` module. So lsmod command misses detailed info of 'Used by'.
When load module, the process is given as follows,
load_module()
-> mod_sysfs_setup()
-> add_usage_links
-> do_init_module
-> mod->init()
add_usage_links func creates holders of target modules linking to
this module. If ref_module is called in mod->init() func, the usage
links cannot be added.
Here, we will add usage link of a to b's holder_dir.
Fixes: 9bea7f239 ("module: fix bne2 "gave up waiting for init of module libcrc32c")
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com>
---
kernel/module.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/module.c b/kernel/module.c
index 80c7c09584cf..11c6aff37b1f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -871,6 +871,11 @@ int ref_module(struct module *a, struct module *b)
module_put(b);
return err;
}
+
+ err = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name);
+ if (err)
+ return err;
+
return 0;
}
EXPORT_SYMBOL_GPL(ref_module);
--
2.19.1
Powered by blists - more mailing lists