From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org, ojeda@kernel.org,
boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
tmgross@umich.edu
Cc: driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH v2 0/5] Use struct devres_node in Devres<T>
Date: Fri, 13 Feb 2026 23:07:10 +0100 [thread overview]
Message-ID: <20260213220718.82835-1-dakr@kernel.org> (raw)
Currently, the Devres<T> container uses devm_add_action() to register a
devres callback.
devm_add_action() allocates a struct action_devres, which on top of
struct devres_node, just keeps a data pointer and release function
pointer.
This is an unnecessary indirection, given that analogous to struct
devres, the Devres<T> container can just embed a struct devres_node
directly without an additional allocation.
In contrast to struct devres, we don't need to force an alignment of
ARCH_DMA_MINALIGN (as struct devres does to account for the worst case)
since we have generics in Rust. I.e. the compiler already ensures
correct alignment of the embedded T in Devres<T>.
Thus, get rid of devm_add_action() and instead embed a struct
devres_node directly.
This patch series is based on [1].
[1] https://lore.kernel.org/lkml/20260202235210.55176-1-dakr@kernel.org/
Changes in v2:
- Prevent driver-core internal C APIs from potentially being called directly
from driver modules due to monomorphisation, to prevent unnecessary symbol
exports.
Danilo Krummrich (5):
devres: move struct devres_node into base.h
devres: export devres_node_init() and devres_node_add()
devres: add devres_node_remove()
devres: rename and export set_node_dbginfo()
rust: devres: embed struct devres_node directly
drivers/base/base.h | 18 +++++
drivers/base/devres.c | 50 ++++++------
rust/kernel/devres.rs | 182 +++++++++++++++++++++++++++++++-----------
3 files changed, 180 insertions(+), 70 deletions(-)
base-commit: 1680377f05a809e4489731ad0e5a5fd5471ec40e
--
2.53.0
next reply other threads:[~2026-02-13 22:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 22:07 Danilo Krummrich [this message]
2026-02-13 22:07 ` [PATCH v2 1/5] devres: move struct devres_node into base.h Danilo Krummrich
2026-02-13 22:07 ` [PATCH v2 2/5] devres: export devres_node_init() and devres_node_add() Danilo Krummrich
2026-02-13 22:07 ` [PATCH v2 3/5] devres: add devres_node_remove() Danilo Krummrich
2026-02-13 22:07 ` [PATCH v2 4/5] devres: rename and export set_node_dbginfo() Danilo Krummrich
2026-02-13 22:07 ` [PATCH v2 5/5] rust: devres: embed struct devres_node directly Danilo Krummrich
2026-02-16 8:29 ` Alice Ryhl
2026-03-12 15:12 ` [PATCH v2 0/5] Use struct devres_node in Devres<T> Greg KH
2026-03-18 0:12 ` Danilo Krummrich
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=20260213220718.82835-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@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