]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Merge patch series "Add support for print exactly once"
authorMiguel Ojeda <ojeda@kernel.org>
Fri, 30 Jan 2026 04:25:30 +0000 (05:25 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Fri, 30 Jan 2026 04:47:10 +0000 (05:47 +0100)
Tomonori writes:

  "This adds the Rust equivalent of the C's DO_ONCE_LITE and pr_*_once
   macros.

   A proposal for this feature was made in the past [1], but it didn't
   reach consensus on the implementation and wasn't merged.

   Unlike the previous proposal, this implements the C's DO_ONCE_LITE
   mechanism using a single atomic variable. While it would be possible
   to implement the feature entirely as a Rust macro, the functionality
   that can be implemented as regular functions has been extracted and
   implemented as the OnceLite struct for better code readability.

   To make it clear that this feature is intended solely for
   print-related functionality (just like in C), the implementation is
   placed in print.rs. If an equivalent of std::sync::Once is needed in
   the future, it should be based on SetOnce rather than OnceLite. Unlike
   std::sync::Once and SetOnce, OnceLite only manages two states:
   incomplete and complete.

   The do_once_lite macro places the OnceLite object in the .data..once
   section, which may be zeroed by memset at any time. While this means
   tear reads might happen, OnceLite only manages two states (zero and
   non-zero), so no actual problem occurs in practice.

   OnceLite currently uses Atomic<i32>, but may be changed to use
   Atomic<i8> [2] when it becomes available."

Link: https://lore.kernel.org/rust-for-linux/20241126-pr_once_macros-v4-0-410b8ca9643e@tuta.io/
Link: https://lore.kernel.org/rust-for-linux/20251115050305.3872412-1-fujita.tomonori@gmail.com/
Link: https://patch.msgid.link/20251117002452.4068692-1-fujita.tomonori@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Trivial merge