Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once
@ 2026-05-18 10:47 Xiaobo Liu
  2026-05-18 11:18 ` Onur Özkan
  0 siblings, 1 reply; 5+ messages in thread
From: Xiaobo Liu @ 2026-05-18 10:47 UTC (permalink / raw)
  To: rust-for-linux, linux-modules
  Cc: linux-kernel, mcgrof, petr.pavlu, da.gomez, samitolvanen, atomlin,
	ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
	tmgross, dakr, Xiaobo Liu

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
---
 rust/kernel/module_param.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
index 6a8a7a875..fedb709fa 100644
--- a/rust/kernel/module_param.rs
+++ b/rust/kernel/module_param.rs
@@ -62,8 +62,8 @@ pub trait ModuleParam: Sized + Copy {
     // NOTE: If we start supporting arguments without values, val _is_ allowed
     // to be null here.
     if val.is_null() {
-        // TODO: Use pr_warn_once available.
-        crate::pr_warn!("Null pointer passed to `module_param::set_param`");
+        crate::pr_warn_once!("Null pointer passed to `module_param::set_param`");
         return EINVAL.to_errno();
     }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once
  2026-05-18 10:47 [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once Xiaobo Liu
@ 2026-05-18 11:18 ` Onur Özkan
  0 siblings, 0 replies; 5+ messages in thread
From: Onur Özkan @ 2026-05-18 11:18 UTC (permalink / raw)
  To: Xiaobo Liu
  Cc: rust-for-linux, linux-modules, linux-kernel, mcgrof, petr.pavlu,
	da.gomez, samitolvanen, atomlin, ojeda, boqun, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr

On Mon, 18 May 2026 18:47:35 +0800
Xiaobo Liu <cppcoffee@gmail.com> wrote:

> Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
> ---

You need to write description for the change.

Onur

>  rust/kernel/module_param.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
> index 6a8a7a875..fedb709fa 100644
> --- a/rust/kernel/module_param.rs
> +++ b/rust/kernel/module_param.rs
> @@ -62,8 +62,8 @@ pub trait ModuleParam: Sized + Copy {
>      // NOTE: If we start supporting arguments without values, val _is_ allowed
>      // to be null here.
>      if val.is_null() {
> -        // TODO: Use pr_warn_once available.
> -        crate::pr_warn!("Null pointer passed to `module_param::set_param`");
> +        crate::pr_warn_once!("Null pointer passed to `module_param::set_param`");
>          return EINVAL.to_errno();
>      }
>  
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once
@ 2026-05-18 13:40 Xiaobo Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Xiaobo Liu @ 2026-05-18 13:40 UTC (permalink / raw)
  To: rust-for-linux, linux-modules
  Cc: linux-kernel, mcgrof, petr.pavlu, da.gomez, samitolvanen, atomlin,
	ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
	tmgross, dakr, Xiaobo Liu

Replace pr_warn!() with pr_warn_once!() in module_param::set_param() to
avoid flooding the kernel log when a null pointer is repeatedly passed.

The original code had a TODO comment noting that pr_warn_once should be
used once available. Since pr_warn_once!() is now available, switch to it
and update the comment accordingly.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
---
 rust/kernel/module_param.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
index 6a8a7a875..fedb709fa 100644
--- a/rust/kernel/module_param.rs
+++ b/rust/kernel/module_param.rs
@@ -62,8 +62,8 @@ pub trait ModuleParam: Sized + Copy {
     // NOTE: If we start supporting arguments without values, val _is_ allowed
     // to be null here.
     if val.is_null() {
-        // TODO: Use pr_warn_once available.
-        crate::pr_warn!("Null pointer passed to `module_param::set_param`");
+        // `pr_warn_once` is already available, use it.
+        crate::pr_warn_once!("Null pointer passed to `module_param::set_param`");
         return EINVAL.to_errno();
     }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once
@ 2026-05-18 13:41 Xiaobo Liu
  2026-05-18 17:37 ` Miguel Ojeda
  0 siblings, 1 reply; 5+ messages in thread
From: Xiaobo Liu @ 2026-05-18 13:41 UTC (permalink / raw)
  To: rust-for-linux, linux-modules
  Cc: linux-kernel, mcgrof, petr.pavlu, da.gomez, samitolvanen, atomlin,
	ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
	tmgross, dakr, Xiaobo Liu

Replace pr_warn!() with pr_warn_once!() in module_param::set_param() to
avoid flooding the kernel log when a null pointer is repeatedly passed.

The original code had a TODO comment noting that pr_warn_once should be
used once available. Since pr_warn_once!() is now available, switch to it
and update the comment accordingly.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
---
 rust/kernel/module_param.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
index 6a8a7a875..fedb709fa 100644
--- a/rust/kernel/module_param.rs
+++ b/rust/kernel/module_param.rs
@@ -62,8 +62,8 @@ pub trait ModuleParam: Sized + Copy {
     // NOTE: If we start supporting arguments without values, val _is_ allowed
     // to be null here.
     if val.is_null() {
-        // TODO: Use pr_warn_once available.
-        crate::pr_warn!("Null pointer passed to `module_param::set_param`");
+        // `pr_warn_once` is already available, use it.
+        crate::pr_warn_once!("Null pointer passed to `module_param::set_param`");
         return EINVAL.to_errno();
     }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once
  2026-05-18 13:41 Xiaobo Liu
@ 2026-05-18 17:37 ` Miguel Ojeda
  0 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-05-18 17:37 UTC (permalink / raw)
  To: Xiaobo Liu, Adarsh Das, Andreas Hindborg
  Cc: rust-for-linux, linux-modules, linux-kernel, mcgrof, petr.pavlu,
	da.gomez, samitolvanen, atomlin, ojeda, boqun, gary, bjorn3_gh,
	lossin, aliceryhl, tmgross, dakr

On Mon, May 18, 2026 at 3:41 PM Xiaobo Liu <cppcoffee@gmail.com> wrote:
>
> Replace pr_warn!() with pr_warn_once!() in module_param::set_param() to
> avoid flooding the kernel log when a null pointer is repeatedly passed.
>
> The original code had a TODO comment noting that pr_warn_once should be
> used once available. Since pr_warn_once!() is now available, switch to it
> and update the comment accordingly.
>
> Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>

Isn't this

  https://lore.kernel.org/rust-for-linux/20260226120848.82891-3-adarshdas950@gmail.com/

and this:

  https://lore.kernel.org/rust-for-linux/20260427-params-pr-once-v1-1-3a8c64704cc4@kernel.org/

? Cc'ing the authors of both. I will reply in the second one too.

(Also, your email seems to have been sent twice to the list)

In any case, Sashiko is correct, this "time-based comment" is not very useful:

> +        // `pr_warn_once` is already available, use it.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-18 17:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18 10:47 [PATCH] rust: kernel: module_param: replace pr_warn with pr_warn_once Xiaobo Liu
2026-05-18 11:18 ` Onur Özkan
  -- strict thread matches above, loose matches on Subject: below --
2026-05-18 13:40 Xiaobo Liu
2026-05-18 13:41 Xiaobo Liu
2026-05-18 17:37 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox