[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250622164050.20358-1-dakr@kernel.org>
Date: Sun, 22 Jun 2025 18:40:37 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: gregkh@...uxfoundation.org,
rafael@...nel.org,
ojeda@...nel.org,
alex.gaynor@...il.com,
boqun.feng@...il.com,
gary@...yguo.net,
bjorn3_gh@...tonmail.com,
lossin@...nel.org,
a.hindborg@...nel.org,
aliceryhl@...gle.com,
tmgross@...ch.edu,
david.m.ertman@...el.com,
ira.weiny@...el.com,
leon@...nel.org,
kwilczynski@...nel.org,
bhelgaas@...gle.com
Cc: rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org,
Danilo Krummrich <dakr@...nel.org>
Subject: [PATCH v2 0/4] Improvements for Devres
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 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 | 362 +++++++++++++++++++++++---------
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, 318 insertions(+), 134 deletions(-)
base-commit: 946d082536c43ed7d394aaba927f3d85eccfc03a
--
2.49.0
Powered by blists - more mailing lists