From: Jessica Yu <jeyu@kernel.org>
To: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Cc: rusty@rustcorp.com.au, kay.sievers@vrfy.org,
clabbe.montjoie@gmail.com, linux-kernel@vger.kernel.org,
"wangxiaogang (F)" <wangxiaogang3@huawei.com>,
"Zhoukang (A)" <zhoukang7@huawei.com>,
Mingfangsen <mingfangsen@huawei.com>
Subject: Re: [PATCH] module: add usage links when calling ref_module func
Date: Mon, 1 Jul 2019 15:55:57 +0200 [thread overview]
Message-ID: <20190701135556.GA25484@linux-8ccs> (raw)
In-Reply-To: <8d7aa8b1-73a2-db7a-82c8-06917eddf235@huawei.com>
+++ Zhiqiang Liu [28/06/19 20:32 +0800]:
>From: Zhiqiang Liu <liuzhiqiang26@huawei.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")
I think we can drop this tag; it doesn't fix a bug specifically
introduced by that particular commit.
>Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.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;
We need to fix the error handling here - the module_use struct
allocated in the call to add_module_usage() needs to be freed (you
could just modify add_module_usage() to return the use pointer so that
it's easier to free from within ref_module()), module_put() needs to
be called, and the use struct should be removed from its respective
lists (see module_unload_free()).
Thanks,
Jessica
next prev parent reply other threads:[~2019-07-01 13:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 12:32 [PATCH] module: add usage links when calling ref_module func Zhiqiang Liu
2019-07-01 13:55 ` Jessica Yu [this message]
2019-07-03 1:28 ` Zhiqiang Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190701135556.GA25484@linux-8ccs \
--to=jeyu@kernel.org \
--cc=clabbe.montjoie@gmail.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuzhiqiang26@huawei.com \
--cc=mingfangsen@huawei.com \
--cc=rusty@rustcorp.com.au \
--cc=wangxiaogang3@huawei.com \
--cc=zhoukang7@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.