[PATCH 0/1] rust: module_param: support bool parameters

Wenzhao Liao posted 1 patch 2 months ago
rust/kernel/module_param.rs  | 9 ++++++++-
rust/macros/lib.rs           | 1 +
rust/macros/module.rs        | 1 +
samples/rust/rust_minimal.rs | 8 ++++++++
4 files changed, 18 insertions(+), 1 deletion(-)
[PATCH 0/1] rust: module_param: support bool parameters
Posted by Wenzhao Liao 2 months ago
Sorry for the earlier noise and for our unfamiliarity with parts of the
kernel submission process, which created extra burden for maintainers.

This patch adds boolean module parameter support to the Rust `module!`
parameter path.

It implements `ModuleParam` for `bool` and wires `PARAM_OPS_BOOL` into
the Rust module parameter machinery, so Rust-side parsing reuses the
existing kernel `kstrtobool()` semantics through `kstrtobool_bytes()`
instead of introducing a separate parser. A boolean parameter is also
added to `samples/rust/rust_minimal.rs` as a small reference user and
build-time validation point.

AI assistance: Codex:GPT-5 was used to help draft the `ModuleParam for
bool` implementation, the macro type mapping, and the sample parameter
wiring. I reviewed the resulting code and changelog, tested the change,
and take responsibility for the submission.

Build-tested with:
  make -C /home/lwz/rfl-dev/worktrees/rnull-upstream-contribution \
    O=/tmp/module-param-bool-build LLVM=-15 defconfig
  make -C /home/lwz/rfl-dev/worktrees/rnull-upstream-contribution \
    O=/tmp/module-param-bool-build LLVM=-15 rustavailable
  scripts/config --file /tmp/module-param-bool-build/.config \
    -e RUST -e SAMPLES -e SAMPLES_RUST -m SAMPLE_RUST_MINIMAL
  make -C /home/lwz/rfl-dev/worktrees/rnull-upstream-contribution \
    O=/tmp/module-param-bool-build LLVM=-15 olddefconfig
  make -C /home/lwz/rfl-dev/worktrees/rnull-upstream-contribution \
    O=/tmp/module-param-bool-build LLVM=-15 vmlinux
  make -C /home/lwz/rfl-dev/worktrees/rnull-upstream-contribution \
    O=/tmp/module-param-bool-build LLVM=-15 samples/rust/rust_minimal.ko

Wenzhao Liao (1):
  rust: module_param: support bool parameters

 rust/kernel/module_param.rs  | 9 ++++++++-
 rust/macros/lib.rs           | 1 +
 rust/macros/module.rs        | 1 +
 samples/rust/rust_minimal.rs | 8 ++++++++
 4 files changed, 18 insertions(+), 1 deletion(-)

-- 
2.34.1
Re: [PATCH 0/1] rust: module_param: support bool parameters
Posted by Greg KH 2 months ago
On Sat, Apr 11, 2026 at 09:02:53AM -0400, Wenzhao Liao wrote:
> Sorry for the earlier noise and for our unfamiliarity with parts of the
> kernel submission process, which created extra burden for maintainers.
> 
> This patch adds boolean module parameter support to the Rust `module!`
> parameter path.
> 
> It implements `ModuleParam` for `bool` and wires `PARAM_OPS_BOOL` into
> the Rust module parameter machinery, so Rust-side parsing reuses the
> existing kernel `kstrtobool()` semantics through `kstrtobool_bytes()`
> instead of introducing a separate parser. A boolean parameter is also
> added to `samples/rust/rust_minimal.rs` as a small reference user and
> build-time validation point.

What driver needs this feature?  Module options should be very rare
going forward as they are 1990's technology and do not fit the "modern"
kernel model at all.

thanks,

greg k-h
Re: [PATCH 0/1] rust: module_param: support bool parameters
Posted by Andreas Hindborg 2 months ago
"Greg KH" <greg@kroah.com> writes:

> On Sat, Apr 11, 2026 at 09:02:53AM -0400, Wenzhao Liao wrote:
>> Sorry for the earlier noise and for our unfamiliarity with parts of the
>> kernel submission process, which created extra burden for maintainers.
>>
>> This patch adds boolean module parameter support to the Rust `module!`
>> parameter path.
>>
>> It implements `ModuleParam` for `bool` and wires `PARAM_OPS_BOOL` into
>> the Rust module parameter machinery, so Rust-side parsing reuses the
>> existing kernel `kstrtobool()` semantics through `kstrtobool_bytes()`
>> instead of introducing a separate parser. A boolean parameter is also
>> added to `samples/rust/rust_minimal.rs` as a small reference user and
>> build-time validation point.
>
> What driver needs this feature?  Module options should be very rare
> going forward as they are 1990's technology and do not fit the "modern"
> kernel model at all.

Rust null block uses module parameters, and was requested to use proper
boolean parsing rather than overloading u8 parsing for boolean
parameters [1].

Best regards,
Andreas Hindborg


[1] https://lore.kernel.org/rust-for-linux/abfK4eji5jKSeO_W@google.com/
Re: [PATCH 0/1] rust: module_param: support bool parameters
Posted by Greg KH 2 months ago
On Mon, Apr 13, 2026 at 02:00:17PM +0200, Andreas Hindborg wrote:
> "Greg KH" <greg@kroah.com> writes:
> 
> > On Sat, Apr 11, 2026 at 09:02:53AM -0400, Wenzhao Liao wrote:
> >> Sorry for the earlier noise and for our unfamiliarity with parts of the
> >> kernel submission process, which created extra burden for maintainers.
> >>
> >> This patch adds boolean module parameter support to the Rust `module!`
> >> parameter path.
> >>
> >> It implements `ModuleParam` for `bool` and wires `PARAM_OPS_BOOL` into
> >> the Rust module parameter machinery, so Rust-side parsing reuses the
> >> existing kernel `kstrtobool()` semantics through `kstrtobool_bytes()`
> >> instead of introducing a separate parser. A boolean parameter is also
> >> added to `samples/rust/rust_minimal.rs` as a small reference user and
> >> build-time validation point.
> >
> > What driver needs this feature?  Module options should be very rare
> > going forward as they are 1990's technology and do not fit the "modern"
> > kernel model at all.
> 
> Rust null block uses module parameters, and was requested to use proper
> boolean parsing rather than overloading u8 parsing for boolean
> parameters [1].
> 
> Best regards,
> Andreas Hindborg
> 
> 
> [1] https://lore.kernel.org/rust-for-linux/abfK4eji5jKSeO_W@google.com/
> 

Ok, then that needs to be said somewhere, and ideally, have the code
that uses that as part of the patch series.

thanks,
greg k-h
Re: [PATCH 0/1] rust: module_param: support bool parameters
Posted by Andreas Hindborg 2 weeks, 4 days ago
Greg KH <greg@kroah.com> writes:

> On Mon, Apr 13, 2026 at 02:00:17PM +0200, Andreas Hindborg wrote:
>> "Greg KH" <greg@kroah.com> writes:
>> 
>> > On Sat, Apr 11, 2026 at 09:02:53AM -0400, Wenzhao Liao wrote:
>> >> Sorry for the earlier noise and for our unfamiliarity with parts of the
>> >> kernel submission process, which created extra burden for maintainers.
>> >>
>> >> This patch adds boolean module parameter support to the Rust `module!`
>> >> parameter path.
>> >>
>> >> It implements `ModuleParam` for `bool` and wires `PARAM_OPS_BOOL` into
>> >> the Rust module parameter machinery, so Rust-side parsing reuses the
>> >> existing kernel `kstrtobool()` semantics through `kstrtobool_bytes()`
>> >> instead of introducing a separate parser. A boolean parameter is also
>> >> added to `samples/rust/rust_minimal.rs` as a small reference user and
>> >> build-time validation point.
>> >
>> > What driver needs this feature?  Module options should be very rare
>> > going forward as they are 1990's technology and do not fit the "modern"
>> > kernel model at all.
>> 
>> Rust null block uses module parameters, and was requested to use proper
>> boolean parsing rather than overloading u8 parsing for boolean
>> parameters [1].
>> 
>> Best regards,
>> Andreas Hindborg
>> 
>> 
>> [1] https://lore.kernel.org/rust-for-linux/abfK4eji5jKSeO_W@google.com/
>> 
>
> Ok, then that needs to be said somewhere, and ideally, have the code
> that uses that as part of the patch series.

It should be mentioned for sure, with a link to the code. I'm not sure
including this patch in the rnull driver series is the right approach.
That series is a really long already. I think using the b4 dependency
feature for dependencies is a better approach for marking dependencies.

I understand that you want to see APIs in context of use, that makes
sense.


Best regards,
Andreas Hindborg