From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org, ojeda@kernel.org,
alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net,
bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
david.m.ertman@intel.com, ira.weiny@intel.com, leon@kernel.org,
kwilczynski@kernel.org, bhelgaas@google.com
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH v3 0/4] Improvements for Devres
Date: Tue, 24 Jun 2025 23:53:58 +0200 [thread overview]
Message-ID: <20250624215600.221167-1-dakr@kernel.org> (raw)
This patch series provides some optimizations for Devres:
1) Provide a more lightweight replacement for Devres::new_foreign_owned().
2) Get rid of Devres' inner Arc and instead consume and provide an
impl PinInit instead.
Additionally, having the resulting explicit synchronization in
Devres::drop() prevents potential subtle undesired side effects of the
devres callback dropping the final Arc reference asynchronously within
the devres callback.
3) An optimization for when we never need to access the resource or release
it manually.
Thanks to Alice and Benno for some great offline discussions on this topic.
This patch series depends on the Opaque patch in [1] and the pin-init patch in
[2], which Benno will provide a signed tag for. A branch containing the patches
can be found in [3].
[1] https://lore.kernel.org/lkml/20250610-b4-rust_miscdevice_registrationdata-v6-1-b03f5dfce998@gmail.com/
[2] https://lore.kernel.org/rust-for-linux/20250529081027.297648-2-lossin@kernel.org/
[3] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/devres
Changes in v3:
- devres::register:
- add 'static bound for ForeignOwnable
- use drop() instead of `let _ =`
- Devres:
- use ptr::from_ref() instead of Inner::as_ptr()
- use &raw mut instead of addr_of_mut!()
- use SAFETY comment proposal from Benno
- add invariant for `Devres::inner`
- use ScopeGuard in devres_callback()
- devres::register_release():
- add impl<T: Release> Release for &T
- add 'static bound for ForeignOwnable
- use drop() instead of `let _ =`
Changes in v2:
- Revocable:
- remove Error: From<E> bound
- devres::register:
- rename devres::register_foreign_boxed() to just devres::register()
- move T: 'static bound to the function rather than the impl block
- Devres:
- Fix aliasing issue by using an Opaque<Inner>; should be
UnsafePinned<Inner> once available.
- Add doc-comments for a couple of private fields.
- Link Revocable on 'revoke' in Devres::new().
- devres::register_release():
- expand documentation of Release
- rename devres::register_foreign_release() for devres::register_release()
Danilo Krummrich (4):
rust: revocable: support fallible PinInit types
rust: devres: replace Devres::new_foreign_owned()
rust: devres: get rid of Devres' inner Arc
rust: devres: implement register_release()
drivers/gpu/nova-core/driver.rs | 7 +-
drivers/gpu/nova-core/gpu.rs | 6 +-
rust/helpers/device.c | 7 +
rust/kernel/cpufreq.rs | 11 +-
rust/kernel/devres.rs | 372 +++++++++++++++++++++++---------
rust/kernel/drm/driver.rs | 14 +-
rust/kernel/pci.rs | 20 +-
rust/kernel/revocable.rs | 6 +-
samples/rust/rust_driver_pci.rs | 19 +-
9 files changed, 327 insertions(+), 135 deletions(-)
base-commit: d752224c81ec2e5c0e86635c4b1cc835f9ca4151
--
2.49.0
next reply other threads:[~2025-06-24 21:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 21:53 Danilo Krummrich [this message]
2025-06-24 21:53 ` [PATCH v3 1/4] rust: revocable: support fallible PinInit types Danilo Krummrich
2025-06-24 21:54 ` [PATCH v3 2/4] rust: devres: replace Devres::new_foreign_owned() Danilo Krummrich
2025-06-24 21:54 ` [PATCH v3 3/4] rust: devres: get rid of Devres' inner Arc Danilo Krummrich
2025-06-26 4:13 ` Boqun Feng
2025-06-26 10:01 ` Danilo Krummrich
2025-06-26 10:27 ` Benno Lossin
2025-06-26 11:07 ` Danilo Krummrich
2025-06-26 11:40 ` Danilo Krummrich
2025-06-26 13:09 ` Benno Lossin
2025-06-26 13:07 ` Benno Lossin
2025-06-26 19:47 ` Danilo Krummrich
2025-06-26 20:04 ` Boqun Feng
2025-06-24 21:54 ` [PATCH v3 4/4] rust: devres: implement register_release() Danilo Krummrich
2025-06-26 10:36 ` Benno Lossin
2025-06-26 11:15 ` Danilo Krummrich
2025-06-26 13:13 ` Benno Lossin
2025-06-26 14:02 ` Danilo Krummrich
2025-06-26 14:41 ` Benno Lossin
2025-06-26 15:32 ` Danilo Krummrich
2025-06-26 15:49 ` Danilo Krummrich
2025-06-26 23:13 ` 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=20250624215600.221167-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=david.m.ertman@intel.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@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).