From: Benno Lossin <benno.lossin@proton.me>
To: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: rust-for-linux@vger.kernel.org
Subject: [PATCH 00/22] make pin-init into a standalone crate
Date: Tue, 04 Mar 2025 22:52:55 +0000 [thread overview]
Message-ID: <20250304225245.2033120-1-benno.lossin@proton.me> (raw)
This patch series extracts the pin-init API from the kernel crate and
turns it into a standalone crate used by the kernel crate. The reasoning
for this change is that the maintenance burden for me is too great
maintaining two (more and more) diverging versions of the same library.
At [1] you can find the user-space version of the pin-init library as a
Rust crate.
The reason for the difference between the two versions is that the
kernel does not use the `std` and `alloc` standard libraries as almost
every other user-space Rust crate does. This not only prevents the
kernel version from implementing features for the `Arc` type from
`alloc`, but also from any `std` types appearing in the documentation.
Additionally, the documentation text is different in several places as
it explicitly mentions the kernel's `Opaque<T>` type.
There are also minor changes in code that occurred due to the same
reason as the documentation changes or due to the non-optimal setup for
synchronizing changes between the two versions (the process it fully
manual, as no diffs can be ported between the two). For example, the
`try_[pin_]init!` macros in the kernel default to the kernel's own
`Error` type. The user-space version does not have such defaulting
behavior.
Since there are other projects outside of the kernel that have begun
using pin-init, the only sensible solution to this problem is to
synchronize both versions and then develop them simultaneously, ensuring
perpetual diff-compatibility. I have even had people contribute code on
github.
Additionally, I want to do some big changes to the pin-init library
internals. For example, porting the proc-macros over to `syn`. We will
probably get support for this later this year in the kernel and I want
to be ready to be able to make that switch as soon as possible. This is
because non-syn proc-macros are just pure hell and the current
implementation is a frankenstein-monster of a mix of declarative macros
and proc-macros that I'd rather replace by using `syn`. I already wrote
the code for that transition and will be submitting an RFC based on this
series shortly.
For these reasons, this patch series extracts all code of the pin-init
API and moves it into a new directory, making it its own crate. Since
the user-space version has some functional differences, these are also
introduced by this series. But in situations where the kernel has
special requirements, extensions to the pin-init crate are reintroduced
in/moved back into the kernel crate. To allow the dream of
diff-compatibility to be true, this series also introduces code files
from the user-space version.
`pin-init` is licensed under APACHE 2.0 OR MIT and almost all code that
is moved already was present with that license. There is a small license
change in patch #2, you can find the explanation in the commit message.
With this change also comes an entry in the MAINTAINERS file, since I
have to synchronize all changes with the user-space version and vice
versa.
For this series I would really appreciate some Tested-by's, by users of
the pin-init library within the kernel in order to ensure that I have
not broken anything.
Special thanks to Miguel for helping me a lot with getting the series
ready!
[1]: https://github.com/Rust-for-Linux/pin-init
---
Cheers,
Benno
Benno Lossin (21):
rust: init: disable doctests
rust: move pin-init API into its own directory
rust: add extensions to the pin-init crate and move relevant
documentation there
rust: pin-init: move proc-macro documentation into pin-init crate
rust: pin-init: change examples to the user-space version
rust: pin-init: call `try_[pin_]init!` from `[pin_]init!` instead of
`__init_internal!`
rust: pin-init: move the default error behavior of `try_[pin_]init`
rust: pin-init: move `InPlaceInit` and impls of `InPlaceWrite` into
the kernel crate
rust: pin-init: move impl `Zeroable` for `Opaque` and
`Option<KBox<T>>` into the kernel crate
rust: add `ZeroableOption` and implement it instead of `Zeroable` for
`Option<Box<T, A>>`
rust: pin-init: fix documentation links
rust: pin-init: remove kernel-crate dependency
rust: pin-init: change the way the `paste!` macro is called
rust: make pin-init its own crate
rust: pin-init: add `std` and `alloc` support from the user-space
version
rust: pin-init: synchronize documentation with the user-space version
rust: pin-init: internal: synchronize with user-space version
rust: pin-init: miscellaneous synchronization with the user-space
version
rust: pin-init: add miscellaneous files from the user-space version
rust: pin-init: re-enable doctests
MAINTAINERS: add entry for the `pin-init` crate
Miguel Ojeda (1):
rust: add pin-init crate build infrastructure
MAINTAINERS | 13 +
rust/Makefile | 75 +-
rust/kernel/alloc/kbox.rs | 9 +-
rust/kernel/block/mq/tag_set.rs | 5 +-
rust/kernel/driver.rs | 6 +-
rust/kernel/init.rs | 1450 ++--------------
rust/kernel/lib.rs | 6 +-
rust/kernel/list.rs | 2 +-
rust/kernel/prelude.rs | 8 +-
rust/kernel/sync/arc.rs | 68 +-
rust/kernel/sync/condvar.rs | 6 +-
rust/kernel/sync/lock.rs | 4 +-
rust/kernel/sync/lock/mutex.rs | 2 +-
rust/kernel/sync/lock/spinlock.rs | 2 +-
rust/kernel/types.rs | 13 +-
rust/macros/helpers.rs | 148 +-
rust/macros/lib.rs | 127 +-
rust/macros/module.rs | 2 +-
rust/macros/quote.rs | 1 +
rust/pin-init/CONTRIBUTING.md | 72 +
rust/pin-init/README.md | 228 +++
rust/pin-init/examples/big_struct_in_place.rs | 39 +
rust/pin-init/examples/error.rs | 27 +
rust/pin-init/examples/linked_list.rs | 161 ++
rust/pin-init/examples/mutex.rs | 209 +++
rust/pin-init/examples/pthread_mutex.rs | 178 ++
rust/pin-init/examples/static_init.rs | 122 ++
rust/pin-init/internal/src/helpers.rs | 152 ++
rust/pin-init/internal/src/lib.rs | 48 +
.../internal/src}/pin_data.rs | 7 +-
.../internal/src}/pinned_drop.rs | 7 +-
.../internal/src}/zeroable.rs | 11 +-
.../init => pin-init/src}/__internal.rs | 43 +-
rust/pin-init/src/alloc.rs | 158 ++
rust/pin-init/src/lib.rs | 1462 +++++++++++++++++
rust/{kernel/init => pin-init/src}/macros.rs | 129 +-
scripts/Makefile.build | 2 +-
scripts/generate_rust_analyzer.py | 17 +-
38 files changed, 3316 insertions(+), 1703 deletions(-)
create mode 100644 rust/pin-init/CONTRIBUTING.md
create mode 100644 rust/pin-init/README.md
create mode 100644 rust/pin-init/examples/big_struct_in_place.rs
create mode 100644 rust/pin-init/examples/error.rs
create mode 100644 rust/pin-init/examples/linked_list.rs
create mode 100644 rust/pin-init/examples/mutex.rs
create mode 100644 rust/pin-init/examples/pthread_mutex.rs
create mode 100644 rust/pin-init/examples/static_init.rs
create mode 100644 rust/pin-init/internal/src/helpers.rs
create mode 100644 rust/pin-init/internal/src/lib.rs
rename rust/{macros => pin-init/internal/src}/pin_data.rs (97%)
rename rust/{macros => pin-init/internal/src}/pinned_drop.rs (92%)
rename rust/{macros => pin-init/internal/src}/zeroable.rs (88%)
rename rust/{kernel/init => pin-init/src}/__internal.rs (86%)
create mode 100644 rust/pin-init/src/alloc.rs
create mode 100644 rust/pin-init/src/lib.rs
rename rust/{kernel/init => pin-init/src}/macros.rs (92%)
base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6
--
2.47.2
next reply other threads:[~2025-03-04 22:53 UTC|newest]
Thread overview: 103+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <xn5HRPkxO91lsoIUAwMnnAvQRCAgmw6nzTZX2DsODS0viAvz_g6B8l3dpYNtcL2jBXySi0DQrVi04b6MY8GbMw==@protonmail.internalid>
2025-03-04 22:52 ` Benno Lossin [this message]
2025-03-04 22:53 ` [PATCH 01/22] rust: init: disable doctests Benno Lossin
2025-03-05 8:51 ` Andreas Hindborg
2025-03-05 12:53 ` Benno Lossin
2025-03-05 13:00 ` Miguel Ojeda
2025-03-05 14:09 ` Andreas Hindborg
2025-03-05 14:31 ` Benno Lossin
2025-03-05 9:17 ` Fiona Behrens
2025-03-04 22:53 ` [PATCH 02/22] rust: move pin-init API into its own directory Benno Lossin
2025-03-05 9:03 ` Andreas Hindborg
2025-03-05 9:17 ` Fiona Behrens
2025-03-04 22:53 ` [PATCH 03/22] rust: add extensions to the pin-init crate and move relevant documentation there Benno Lossin
2025-03-05 9:11 ` Andreas Hindborg
2025-03-05 11:03 ` Benno Lossin
2025-03-05 9:17 ` Fiona Behrens
2025-03-04 22:53 ` [PATCH 04/22] rust: pin-init: move proc-macro documentation into pin-init crate Benno Lossin
2025-03-05 9:18 ` Fiona Behrens
2025-03-05 9:34 ` Andreas Hindborg
2025-03-05 11:05 ` Benno Lossin
2025-03-04 22:53 ` [PATCH 05/22] rust: pin-init: change examples to the user-space version Benno Lossin
2025-03-05 9:19 ` Fiona Behrens
2025-03-05 10:06 ` Andreas Hindborg
2025-03-04 22:53 ` [PATCH 06/22] rust: pin-init: call `try_[pin_]init!` from `[pin_]init!` instead of `__init_internal!` Benno Lossin
2025-03-05 9:19 ` Fiona Behrens
2025-03-05 10:12 ` Andreas Hindborg
2025-03-04 22:54 ` [PATCH 07/22] rust: pin-init: move the default error behavior of `try_[pin_]init` Benno Lossin
2025-03-05 9:21 ` Fiona Behrens
2025-03-05 10:29 ` Andreas Hindborg
2025-03-05 10:47 ` Benno Lossin
2025-03-04 22:54 ` [PATCH 08/22] rust: pin-init: move `InPlaceInit` and impls of `InPlaceWrite` into the kernel crate Benno Lossin
2025-03-05 9:23 ` Fiona Behrens
2025-03-05 11:18 ` Andreas Hindborg
2025-03-05 12:06 ` Benno Lossin
2025-03-05 12:28 ` Andreas Hindborg
2025-03-05 12:37 ` Benno Lossin
2025-03-04 22:54 ` [PATCH 09/22] rust: pin-init: move impl `Zeroable` for `Opaque` and `Option<KBox<T>>` " Benno Lossin
2025-03-05 9:24 ` Fiona Behrens
2025-03-05 11:26 ` Andreas Hindborg
2025-03-05 12:05 ` Benno Lossin
2025-03-05 12:11 ` Alice Ryhl
2025-03-05 12:17 ` Benno Lossin
2025-03-05 12:49 ` Alice Ryhl
2025-03-05 12:51 ` Benno Lossin
2025-03-04 22:54 ` [PATCH 10/22] rust: add `ZeroableOption` and implement it instead of `Zeroable` for `Option<Box<T, A>>` Benno Lossin
2025-03-05 9:25 ` Fiona Behrens
2025-03-05 11:30 ` Andreas Hindborg
2025-03-04 22:54 ` [PATCH 11/22] rust: pin-init: fix documentation links Benno Lossin
2025-03-05 9:26 ` Fiona Behrens
2025-03-05 11:37 ` Andreas Hindborg
2025-03-05 11:49 ` Benno Lossin
2025-03-04 22:54 ` [PATCH 12/22] rust: pin-init: remove kernel-crate dependency Benno Lossin
2025-03-05 9:27 ` Fiona Behrens
2025-03-05 11:49 ` Andreas Hindborg
2025-03-05 12:00 ` Benno Lossin
2025-03-05 12:27 ` Andreas Hindborg
2025-03-04 22:55 ` [PATCH 13/22] rust: pin-init: change the way the `paste!` macro is called Benno Lossin
2025-03-05 9:28 ` Fiona Behrens
2025-03-05 11:52 ` Andreas Hindborg
2025-03-04 22:55 ` [PATCH 14/22] rust: add pin-init crate build infrastructure Benno Lossin
2025-03-05 11:59 ` Andreas Hindborg
2025-03-05 12:10 ` Benno Lossin
2025-03-05 12:31 ` Andreas Hindborg
2025-03-05 12:50 ` Miguel Ojeda
2025-03-05 13:00 ` Benno Lossin
2025-03-05 14:19 ` Andreas Hindborg
2025-03-05 14:34 ` Benno Lossin
2025-03-05 12:47 ` Miguel Ojeda
2025-03-04 22:55 ` [PATCH 15/22] rust: make pin-init its own crate Benno Lossin
2025-03-05 9:29 ` Fiona Behrens
2025-03-05 12:12 ` Andreas Hindborg
2025-03-05 13:40 ` Benno Lossin
2025-03-05 14:20 ` Andreas Hindborg
2025-03-04 22:55 ` [PATCH 16/22] rust: pin-init: add `std` and `alloc` support from the user-space version Benno Lossin
2025-03-05 9:32 ` Fiona Behrens
2025-03-05 12:22 ` Andreas Hindborg
2025-03-05 13:55 ` Benno Lossin
2025-03-05 14:29 ` Andreas Hindborg
2025-03-05 15:05 ` Benno Lossin
2025-03-05 17:27 ` Andreas Hindborg
2025-03-04 22:55 ` [PATCH 17/22] rust: pin-init: synchronize documentation with " Benno Lossin
2025-03-05 9:33 ` Fiona Behrens
2025-03-05 12:52 ` Andreas Hindborg
2025-03-04 22:55 ` [PATCH 18/22] rust: pin-init: internal: synchronize with " Benno Lossin
2025-03-05 12:56 ` Andreas Hindborg
2025-03-04 22:56 ` [PATCH 19/22] rust: pin-init: miscellaneous synchronization with the " Benno Lossin
2025-03-05 12:57 ` Andreas Hindborg
2025-03-04 22:56 ` [PATCH 20/22] rust: pin-init: add miscellaneous files from " Benno Lossin
2025-03-05 9:35 ` Fiona Behrens
2025-03-05 13:04 ` Andreas Hindborg
2025-03-05 13:37 ` Miguel Ojeda
2025-03-05 13:58 ` Benno Lossin
2025-03-04 22:56 ` [PATCH 21/22] rust: pin-init: re-enable doctests Benno Lossin
2025-03-05 9:35 ` Fiona Behrens
2025-03-05 13:05 ` Andreas Hindborg
2025-03-04 22:56 ` [PATCH 22/22] MAINTAINERS: add entry for the `pin-init` crate Benno Lossin
2025-03-05 0:17 ` Jarkko Sakkinen
2025-03-05 0:43 ` Benno Lossin
2025-03-05 5:14 ` Jarkko Sakkinen
2025-03-04 23:12 ` [PATCH 00/22] make pin-init into a standalone crate Benno Lossin
2025-03-05 13:56 ` Andreas Hindborg
2025-03-05 14:03 ` Benno Lossin
2025-03-05 14:36 ` Andreas Hindborg
2025-03-05 14:47 ` Benno Lossin
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=20250304225245.2033120-1-benno.lossin@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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;
as well as URLs for NNTP newsgroup(s).