From: Youling Tang <youling.tang@linux.dev>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-arch@vger.kernel.org, Youling Tang <tangyouling@kylinos.cn>,
linux-f2fs-devel@lists.sourceforge.net, tytso@mit.edu,
Arnd Bergmann <arnd@arndb.de>, Josef Bacik <josef@toxicpanda.com>,
linux-kernel@vger.kernel.org, Chris Mason <clm@fb.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>,
Jaegeuk Kim <jaegeuk@kernel.org>,
linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros
Date: Wed, 24 Jul 2024 09:57:05 +0800 [thread overview]
Message-ID: <0a63dfd1-ead3-4db3-a38c-2bc1db65f354@linux.dev> (raw)
In-Reply-To: <Zp-_RDk5n5431yyh@infradead.org>
Hi, Christoph
On 23/07/2024 22:33, Christoph Hellwig wrote:
> On Tue, Jul 23, 2024 at 04:32:36PM +0800, Youling Tang wrote:
>> Providing module_subinit{_noexit} and module_subeixt helps macros ensure
>> that modules init/exit match their order, while also simplifying the code.
>>
>> The three macros are defined as follows:
>> - module_subinit(initfn, exitfn,rollback)
>> - module_subinit_noexit(initfn, rollback)
>> - module_subexit(rollback)
>>
>> `initfn` is the initialization function and `exitfn` is the corresponding
>> exit function.
> I find the interface a little confusing. What I would have expected
> is to:
>
> - have the module_subinit call at file scope instead of in the
> module_init helper, similar to module_init/module_exit
> - thus keep the rollback state explicitly in the module structure or
> similar so that the driver itself doesn't need to care about at
> all, and thus remove the need for the module_subexit call.
module_init(initfn)/module_exit(exitfn) has two definitions (via MODULE):
- buindin: uses do_initcalls() to iterate over the contents of the specified
section and executes all initfn functions in the section in the order in
which they are stored (exitfn is not required).
- ko: run do_init_module(mod)->do_one_initcall(mod->init) to execute initfn
of the specified module.
If we change module_subinit to something like this, not called in
module_init,
```
static int init_a(void)
{
...
return 0;
}
static void exit_a(void)
{
...
}
subinitcall(init_a, exit_a);
static int init_b(void)
{
...
return 0;
}
static void exit_b(void)
{
...
}
subinitcall(init_b, exit_b);
```
Not only do we want to ensure that exit is executed in reverse order of
init, but we also want to ensure the order of init.
This does not guarantee the order in which init will be executed (although
the init/exit order will remain the same)
Tanks,
Youling.
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2024-07-24 1:57 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 8:32 [f2fs-dev] [PATCH 0/4] Add module_subinit{_noexit} and module_subeixt helper macros Youling Tang
2024-07-23 8:32 ` [f2fs-dev] [PATCH 1/4] module: " Youling Tang
2024-07-23 9:58 ` Mika Penttilä
2024-07-24 1:20 ` Youling Tang
2024-07-23 14:33 ` Christoph Hellwig
2024-07-24 1:57 ` Youling Tang [this message]
2024-07-24 15:43 ` Christoph Hellwig
2024-07-25 3:01 ` Youling Tang
2024-07-25 14:39 ` Christoph Hellwig
2024-07-25 15:30 ` Arnd Bergmann
2024-07-25 15:34 ` Christoph Hellwig
2024-07-25 17:14 ` Goffredo Baroncelli via Linux-f2fs-devel
2024-07-25 19:46 ` Christoph Hellwig
2024-07-26 8:54 ` Youling Tang
2024-07-26 14:04 ` Christoph Hellwig
2024-07-26 15:22 ` David Sterba
2024-07-26 17:58 ` Theodore Ts'o
2024-07-26 18:09 ` Christoph Hellwig
2024-07-26 22:45 ` David Sterba
2024-07-27 14:52 ` Theodore Ts'o
2024-07-29 1:46 ` Youling Tang
2024-07-29 2:44 ` Theodore Ts'o
2024-07-29 3:01 ` Youling Tang
2024-07-29 18:57 ` Christoph Hellwig
2024-07-23 8:32 ` [f2fs-dev] [PATCH 2/4] btrfs: Use " Youling Tang
2024-07-23 22:24 ` kernel test robot
2024-07-24 6:29 ` Youling Tang
2024-07-23 8:32 ` [f2fs-dev] [PATCH 3/4] ext4: Use module_{subinit, subexit} " Youling Tang
2024-07-23 8:32 ` [f2fs-dev] [PATCH 4/4] f2fs: Use module_{subinit, subeixt} " Youling Tang
2024-07-23 18:51 ` kernel test robot
2024-07-24 2:14 ` Youling Tang
2024-07-23 21:31 ` kernel test robot
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=0a63dfd1-ead3-4db3-a38c-2bc1db65f354@linux.dev \
--to=youling.tang@linux.dev \
--cc=adilger.kernel@dilger.ca \
--cc=arnd@arndb.de \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=hch@infradead.org \
--cc=jaegeuk@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=tangyouling@kylinos.cn \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).