Linux Modules
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Petr Pavlu" <petr.pavlu@suse.com>, "Aaron Tomlin" <atomlin@atomlin.com>
Cc: <arnd@arndb.de>, <mcgrof@kernel.org>, <da.gomez@kernel.org>,
	<samitolvanen@google.com>, <peterz@infradead.org>,
	<ojeda@kernel.org>, <akpm@linux-foundation.org>,
	<mhiramat@kernel.org>, <boqun@kernel.org>, <neelx@suse.com>,
	<da.anzani@gmail.com>, <sean@ashe.io>, <chjohnst@mail.com>,
	<steve@abita.co>, <mproche@mail.com>, <nick.lane@mail.com>,
	<linux-arch@vger.kernel.org>, <linux-modules@vger.kernel.org>,
	<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v9 1/2] module: Extend module_blacklist parameter to built-in modules
Date: Thu, 13 Aug 2026 15:56:53 +0100	[thread overview]
Message-ID: <DKNWJNKYK5HY.1BZYPRXP3BZSS@garyguo.net> (raw)
In-Reply-To: <af6aaa0a-03de-4175-84a5-7c253198d184@suse.com>

On Thu Aug 13, 2026 at 3:15 PM BST, Petr Pavlu wrote:
> On 8/7/26 3:26 AM, Aaron Tomlin wrote:
>> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
>> index 5659f4b5a125..799d912dcbc0 100644
>> --- a/include/asm-generic/vmlinux.lds.h
>> +++ b/include/asm-generic/vmlinux.lds.h
>> @@ -734,7 +734,9 @@
>>  	EARLYCON_TABLE()						\
>>  	LSM_TABLE()							\
>>  	EARLY_LSM_TABLE()						\
>> -	KUNIT_INIT_TABLE()
>> +	KUNIT_INIT_TABLE()						\
>> +	STRUCT_ALIGN();							\
>> +	BOUNDED_SECTION_BY(.initcall.modnames, _initcall_modnames)
>>  
>>  #define INIT_TEXT							\
>>  	*(.init.text .init.text.*)					\
>
> I realized that instead of using STRUCT_ALIGN(), a cleaner and less
> wasteful approach is to prevent any potential over-alignment of
> individual .initcall.modnames sections by having
> ____define_initcall_modname() define each `struct initcall_modname` with
> `__aligned(__alignof__(struct initcall_modname))`.
>
>> diff --git a/rust/macros/module.rs b/rust/macros/module.rs
>> index 06c18e207508..13353b43b38d 100644
>> --- a/rust/macros/module.rs
>> +++ b/rust/macros/module.rs
>> @@ -479,6 +479,7 @@ pub(crate) fn module(info: ModuleInfo) -> Result<TokenStream> {
>>      let ident_init = format_ident!("__{ident}_init");
>>      let ident_exit = format_ident!("__{ident}_exit");
>>      let ident_initcall = format_ident!("__{ident}_initcall");
>> +    let ident_modname = format_ident!("__{ident}_modname");
>>      let initcall_section = ".initcall6.init";
>>  
>>      let global_asm = format!(
>> @@ -590,6 +591,21 @@ pub extern "C" fn cleanup_module() {
>>                  #[cfg(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)]
>>                  ::core::arch::global_asm!(#global_asm);
>>  
>> +                #[cfg(not(MODULE))]
>> +                #[repr(C)]
>> +                struct InitcallModname {
>> +                    initcall_fn: extern "C" fn() -> ::kernel::ffi::c_int,
>> +                    modname: *const ::kernel::ffi::c_char,
>> +                }
>> +
>> +                #[cfg(not(MODULE))]
>> +                #[used(compiler)]
>> +                #[link_section = ".initcall.modnames"]
>> +                static #ident_modname: InitcallModname = InitcallModname {
>
> Can Rust directly use the C definition of initcall_modname via
> ::kernel::bindings::initcall_modname?
>
>> +                    initcall_fn: #ident_init,
>> +                    modname: #name_cstr.as_ptr().cast(),
>
> Can the modname string be placed in .init.rodata to match the behavior
> on the C side?

Putting strings in .init.rodata is more likely to grow the size of kernel
because it cannot be deduplicated with other strings; the names are very likely
to be in .rodata already due to it being added to sysfs when registering with a
bus.

Best,
Gary

>
>> +                };
>> +
>>                  #[cfg(not(MODULE))]
>>                  #[no_mangle]
>>                  pub extern "C" fn #ident_init() -> ::kernel::ffi::c_int {



  reply	other threads:[~2026-08-13 14:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  1:25 [PATCH v9 0/2] module: Extend module_blacklist parameter to built-in modules Aaron Tomlin
2026-08-07  1:26 ` [PATCH v9 1/2] " Aaron Tomlin
2026-08-13 14:15   ` Petr Pavlu
2026-08-13 14:56     ` Gary Guo [this message]
2026-08-07  1:26 ` [PATCH v9 2/2] module: Rename module_blacklist to module_denylist Aaron Tomlin
2026-08-07  1:37   ` sashiko-bot
2026-08-13 14:50 ` [PATCH v9 0/2] module: Extend module_blacklist parameter to built-in modules Gary Guo

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=DKNWJNKYK5HY.1BZYPRXP3BZSS@garyguo.net \
    --to=gary@garyguo.net \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=atomlin@atomlin.com \
    --cc=boqun@kernel.org \
    --cc=chjohnst@mail.com \
    --cc=da.anzani@gmail.com \
    --cc=da.gomez@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mproche@mail.com \
    --cc=neelx@suse.com \
    --cc=nick.lane@mail.com \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=petr.pavlu@suse.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=sean@ashe.io \
    --cc=steve@abita.co \
    /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