| From: |
| Jens Korinth via B4 Relay <devnull+jens.korinth.tuta.io-AT-kernel.org> |
| To: |
| Miguel Ojeda <ojeda-AT-kernel.org>, Alex Gaynor <alex.gaynor-AT-gmail.com>, Boqun Feng <boqun.feng-AT-gmail.com>, Gary Guo <gary-AT-garyguo.net>, Björn Roy Baron <bjorn3_gh-AT-protonmail.com>, Benno Lossin <benno.lossin-AT-proton.me>, Andreas Hindborg <a.hindborg-AT-kernel.org>, Alice Ryhl <aliceryhl-AT-google.com>, Trevor Gross <tmgross-AT-umich.edu> |
| Subject: |
| [PATCH v4 0/3] rust: Add pr_*_once macros |
| Date: |
| Tue, 26 Nov 2024 17:40:56 +0100 |
| Message-ID: |
| <20241126-pr_once_macros-v4-0-410b8ca9643e@tuta.io> |
| Cc: |
| rust-for-linux-AT-vger.kernel.org, FUJITA Tomonori <fujita.tomonori-AT-gmail.com>, Dirk Behme <dirk.behme-AT-gmail.com>, linux-kernel-AT-vger.kernel.org, Jens Korinth <jens.korinth-AT-tuta.io> |
| Archive-link: |
| Article |
Add Rust version of pr_[emerg|alert|crit|err|warn|notic|info]_once
functions, which print a message only once.
Introduces a `OnceLite` abstraction similar to Rust's
[`std::sync::Once`](https://doc.rust-lang.org/std/sync/struct.Once.html)
but using the non-blocking mechanism from the kernel's `DO_ONCE_LITE`
macro, which is used to define the `do_once_lite` Rust macro.
First use case are an implementation of `pr_*_once` message macros to
print a message only once.
v4:
- Move `do_once_lite` macro implementation to `OnceLite` abstraction
- Use `OnceLite` in `do_once_lite`
- More documentation, examples
v3: https://lore.kernel.org/rust-for-linux/20241109-pr_once_m...
- Fix rustdoc error, formatting issues
- Fix missing Signed-off-by
v2: https://lore.kernel.org/r/20241107-pr_once_macros-v2-0-dc...
- Split patch into do_once_lite part and pr_*_once macros
- Add macro rule for call without condition => renamed to do_once_lite
- Used condition-less call in pr_*_once macros
- Added examples
- Removed TODO in kernel/error.rs using pr_warn_once
v1: https://lore.kernel.org/rust-for-linux/20241106.083113.35...
Co-developed-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Jens Korinth <jens.korinth@tuta.io>
---
FUJITA Tomonori (1):
rust: print: Add pr_*_once macros
Jens Korinth (2):
rust: Add `OnceLite` for executing code once
rust: error: Replace pr_warn by pr_warn_once
rust/kernel/error.rs | 3 +-
rust/kernel/lib.rs | 1 +
rust/kernel/once_lite.rs | 127 +++++++++++++++++++++++++++++++++++++++++++++++
rust/kernel/print.rs | 126 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 255 insertions(+), 2 deletions(-)
---
base-commit: b2603f8ac8217bc59f5c7f248ac248423b9b99cb
change-id: 20241107-pr_once_macros-6438e6f5b923
Best regards,
--
Jens Korinth <jens.korinth@tuta.io>