The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: "Benno Lossin" <lossin@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Gary Guo <gary@garyguo.net>
Subject: [PATCH 0/4] rust: pin-init: merge `__init` and `__pinned_init`
Date: Wed, 22 Jul 2026 19:50:14 +0100	[thread overview]
Message-ID: <20260722-merge-init-v1-0-d4594de76538@garyguo.net> (raw)

Currently we have `PinInit::__pinned_init` and `Init::__init` which has
slightly different safety requirement but are required to do the same
thing. Instead of having to duplicate impl everywhere, it's simpler to just
use `Init` as a marker trait that cancels out the pinning requirement on
`PinInit::__pinned_init`. This also simplifies code (and shorten the symbol
name) so `__init` can always be used.

Note that to pull off this change it needs a stage approach. The plan is:
* Patch 1 (the `__pinned_init` and `__init` merge) is to be taken this
  cycle through pin-init tree; this preserves the `__pinned_init` method as
  an alias for compatibility.
* Patch 2 can be taken via driver-core this cycle.
* Patch 3 (tree-wide changes) to be taken next cycle. I can split this
  further up next cycle so this can be routed via various subsystems.
* Patch 4 (removal of `__pinned_init`) is to be taken via pin-init two
  cycles after.

---
This might be an opportunity to rethink about the API. IIRC we use `__init`
initially to avoid conflicts because we have the blanket impl on `T` and
`Result<T, E>`.

Maybe we should get rid of the underscores and name it something more
proper, like `init_ptr`, or maybe add an extension trait to raw pointers
type so you can do

    unsafe { raw_ptr.init(something_that_impls_pin_init) }

?

To: Benno Lossin <lossin@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>
To: Boqun Feng <boqun@kernel.org>
To: Björn Roy Baron <bjorn3_gh@protonmail.com>
To: Andreas Hindborg <a.hindborg@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
To: Trevor Gross <tmgross@umich.edu>
To: Danilo Krummrich <dakr@kernel.org>
To: Daniel Almeida <daniel.almeida@collabora.com>
To: Tamir Duberstein <tamird@kernel.org>
To: Alexandre Courbot <acourbot@nvidia.com>
To: Onur Özkan <work@onurozkan.dev>
Cc: rust-for-linux@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Gary Guo <gary@garyguo.net>

---
Gary Guo (4):
      rust: pin-init: merge `__pinned_init` and `__init`
      rust: devres: use `cast_pin_init` instead of manual reimplementation
      rust: treewide: replace `__pinned_init` with `__init`
      rust: pin-init: remove `__pinned_init` method for `cfg(kernel)`

 rust/kernel/alloc/kbox.rs             |   6 +-
 rust/kernel/devres.rs                 |   6 +-
 rust/kernel/drm/device.rs             |   2 +-
 rust/kernel/drm/gpuvm/va.rs           |   2 +-
 rust/kernel/drm/gpuvm/vm_bo.rs        |   2 +-
 rust/kernel/init.rs                   |  10 +--
 rust/kernel/pwm.rs                    |   2 +-
 rust/kernel/sync/arc.rs               |   4 +-
 rust/kernel/types.rs                  |   2 +-
 rust/macros/module.rs                 |   2 +-
 rust/pin-init/examples/mutex.rs       |   2 +-
 rust/pin-init/examples/static_init.rs |   9 +--
 rust/pin-init/src/__internal.rs       |   8 +-
 rust/pin-init/src/alloc.rs            |   6 +-
 rust/pin-init/src/lib.rs              | 147 ++++++++++++++--------------------
 15 files changed, 85 insertions(+), 125 deletions(-)
---
base-commit: b4515cf4156356e8f4fe6e0fdc17f59adab9772f
change-id: 20260722-merge-init-3ed98519ec7f

Best regards,
--  
Gary Guo <gary@garyguo.net>


             reply	other threads:[~2026-07-22 18:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 18:50 Gary Guo [this message]
2026-07-22 18:50 ` [PATCH 1/4] rust: pin-init: merge `__pinned_init` and `__init` Gary Guo
2026-07-22 18:50 ` [PATCH 2/4] rust: devres: use `cast_pin_init` instead of manual reimplementation Gary Guo
2026-07-22 18:50 ` [PATCH 3/4] rust: treewide: replace `__pinned_init` with `__init` Gary Guo
2026-07-22 18:50 ` [PATCH 4/4] rust: pin-init: remove `__pinned_init` method for `cfg(kernel)` Gary Guo

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=20260722-merge-init-v1-0-d4594de76538@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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