From: Shashank Balaji <shashank.mahadasyam@sony.com>
To: Petr Pavlu <petr.pavlu@suse.com>
Cc: "Suzuki K Poulose" <suzuki.poulose@arm.com>,
"James Clark" <james.clark@linaro.org>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Daniel Gomez" <da.gomez@kernel.org>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Aaron Tomlin" <atomlin@atomlin.com>,
"Mike Leach" <mike.leach@arm.com>, "Leo Yan" <leo.yan@arm.com>,
"Thierry Reding" <thierry.reding@kernel.org>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Rahul Bukte" <rahul.bukte@sony.com>,
linux-kernel@vger.kernel.org, coresight@lists.linaro.org,
linux-arm-kernel@lists.infradead.org,
driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-doc@vger.kernel.org,
"Daniel Palmer" <daniel.palmer@sony.com>,
"Tim Bird" <tim.bird@sony.com>,
linux-modules@vger.kernel.org, linux-tegra@vger.kernel.org,
"Sumit Gupta" <sumitg@nvidia.com>
Subject: Re: [PATCH v5 2/4] kernel: param: initialize module_kset in a pure_initcall
Date: Sat, 23 May 2026 12:24:18 +0900 [thread overview]
Message-ID: <ahEd4iC-2hqUbMy3@JPC00244420> (raw)
In-Reply-To: <a0b17be8-f7dd-4d05-bc6f-28b32d0b0785@suse.com>
Hi Petr,
Thanks for the feedback!
On Fri, May 22, 2026 at 03:06:04PM +0200, Petr Pavlu wrote:
> On 5/18/26 12:19 PM, Shashank Balaji wrote:
> > Commit "driver core: platform: set mod_name in driver registration" will set
> > struct device_driver's mod_name member for platform driver registration. For a
> > driver to be registered with its mod_name set, module_kset needs to be
> > initialized, which currently happens in a subsys_initcall in param_sysfs_init().
> > The tegra cbb drivers register themselves before module_kset init, in a
> > core_initcall. This works currently because lookup_or_create_module_kobject(),
> > which dereferences module_kset via kset_find_obj(), is not called if mod_name
> > is not set, which is the case now.
> >
> > So in preparation for the commit "driver core: platform: set mod_name in driver registration",
> > move module_kset init to pure_initcall level, ensuring it happens before tegra
> > cbb driver registration.
> >
> > Suggested-by: Gary Guo <gary@garyguo.net>
> > Co-developed-by: Rahul Bukte <rahul.bukte@sony.com>
> > Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
> > Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
> > ---
> > Patch 4 depends on this patch
> > ---
> > kernel/params.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/params.c b/kernel/params.c
> > index 74d620bc2521..ac088d4b09a9 100644
> > --- a/kernel/params.c
> > +++ b/kernel/params.c
> > @@ -957,7 +957,7 @@ static int __init param_sysfs_init(void)
> >
> > return 0;
> > }
> > -subsys_initcall(param_sysfs_init);
> > +pure_initcall(param_sysfs_init);
> >
> > /*
> > * param_sysfs_builtin_init - add sysfs version and parameter
> >
>
> The change looks ok to me functionality-wise. Sysfs is initialized
> earlier in do_basic_setup() and other code, such as classes_init(),
> calls kset_create_and_add() similarly early.
>
> One minor issue is that pure_initcall() was originally intended for
> static variable initialization. The file include/linux/init.h says:
>
> | /*
> | * A "pure" initcall has no dependencies on anything else, and purely
> | * initializes variables that couldn't be statically initialized.
> | *
> | * This only exists for built-in code, not for modules.
> | * Keep main.c:initcall_level_names[] in sync.
> | */
> | #define pure_initcall(fn) __define_initcall(fn, 0)
>
> The patch stretches the intended use of pure_initcall() somewhat in this
> regard. However, other code already appears to do the same, so I guess
> this is ok.
Ah yeah, I thought of this too, but it seems like everyone else is doing
it. Linus introduced pure_initcall in b3438f8266cb
("Add "pure_initcall" for static variable initialization") with the
comment, and he introduced another user of it in 140d0b2108fa
("Do 'shm_init_ns()' in an early pure_initcall") which already stretches
the intended use as per the comment.
Given that it's just being used for "run me before core_initcall;
early_initcall is too early for me" without any "pureness" requirements, I
suppose the comment is due for a revision?
> Additionally, I think it would be good to update the comment preceding
> param_sysfs_init(). It currently says:
>
> | /*
> | * param_sysfs_init - create "module" kset
> | *
> | * This must be done before the initramfs is unpacked and
> | * request_module() thus becomes possible, because otherwise the
> | * module load would fail in mod_sysfs_init.
> | */
>
> I suggest changing it to something like follows:
>
> This must be done before any driver registration so that when a driver comes
> from a built-in module, the driver core can add the module under /sys/module
> and create the associated driver symlinks.
Thanks for catching this! I'll add it in the next revision.
Thanks,
Shashank
next prev parent reply other threads:[~2026-05-23 3:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260422-acpi_mod_name-v3-0-a184eff9ff6f@sony.com>
2026-04-27 2:41 ` [PATCH v4 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-27 2:41 ` [PATCH v4 1/4] kernel: param: initialize module_kset before do_initcalls() Shashank Balaji
2026-04-27 13:29 ` Gary Guo
2026-04-28 0:37 ` Shashank Balaji
2026-04-28 11:10 ` Gary Guo
2026-04-28 13:07 ` Shashank Balaji
2026-05-12 2:12 ` Shashank Balaji
2026-05-12 8:55 ` Jon Hunter
2026-05-12 12:14 ` Sumit Gupta
2026-05-12 13:32 ` Shashank Balaji
2026-04-27 2:41 ` [PATCH v4 2/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-04-27 10:49 ` Leo Yan
2026-04-27 2:41 ` [PATCH v4 3/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-27 2:41 ` [PATCH v4 4/4] docs: driver-api: add mod_name argument to __platform_register_drivers() Shashank Balaji
2026-05-18 10:19 ` [PATCH v5 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-05-18 10:19 ` [PATCH v5 1/4] soc/tegra: cbb: Move driver registration from pure_initcall to core_initcall Shashank Balaji
2026-05-18 10:19 ` [PATCH v5 2/4] kernel: param: initialize module_kset in a pure_initcall Shashank Balaji
2026-05-22 13:06 ` Petr Pavlu
2026-05-23 3:24 ` Shashank Balaji [this message]
2026-05-18 10:19 ` [PATCH v5 3/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-05-18 10:20 ` [PATCH v5 4/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-05-18 10:27 ` Greg Kroah-Hartman
2026-05-18 10:32 ` Shashank Balaji
2026-05-18 10:49 ` Greg Kroah-Hartman
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=ahEd4iC-2hqUbMy3@JPC00244420 \
--to=shashank.mahadasyam@sony.com \
--cc=a.hindborg@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=aliceryhl@google.com \
--cc=atomlin@atomlin.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=da.gomez@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.palmer@sony.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=james.clark@linaro.org \
--cc=jonathanh@nvidia.com \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mcgrof@kernel.org \
--cc=mike.leach@arm.com \
--cc=ojeda@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rafael@kernel.org \
--cc=rahul.bukte@sony.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=skhan@linuxfoundation.org \
--cc=sumitg@nvidia.com \
--cc=suzuki.poulose@arm.com \
--cc=thierry.reding@kernel.org \
--cc=tim.bird@sony.com \
--cc=tmgross@umich.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