public inbox for rcu@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] Introduce HasField infrastructure
@ 2026-01-28 21:53 Boqun Feng
  2026-01-28 21:53 ` [RFC PATCH 1/7] rust: types: Introduce HasField trait and derive macro Boqun Feng
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Boqun Feng @ 2026-01-28 21:53 UTC (permalink / raw)
  To: linux-kernel, rust-for-linux, rcu
  Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Christian Brauner, Carlos Llamas, Alice Ryhl, Miguel Ojeda,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Zqiang, FUJITA Tomonori,
	Lyude Paul, Thomas Gleixner, Anna-Maria Behnsen, John Stultz,
	Stephen Boyd, Yury Norov (NVIDIA), Vitaly Wool, Tamir Duberstein,
	Viresh Kumar, Daniel Almeida, Mitchell Levy, David Gow,
	Peter Novak, José Expósito

Currently we have a few similar places where we use a `Has*` trait to
describe that a data structure has some types of field in it so that the
containing type can do something with it. There are also a `impl_has_*!`
macro to help implement the trait. While it's working, but it's less
ergonomic to me, especially considering the amount of the work we need
to do for something new (e.g. rcu_head).

Therefore here is the effort to unify them into a proc-macro based
solution. `Field` and `HasField` traits are introduced to generify the
"Has A" relationship, and a derive macro `#[derive(HasField)]` is also
added to support automatically implementing `HasField` trait.

This series convert a few users (Work, HrTimer) and introduce a new
`Field` type `RcuHead`. These improvements demonstrate how this
infrastructure can be used.

Some future work is still needed: using `HasField` for `DelayedWork` and
`ListLink` is still missing. Also it's possible to clean up `HasWork`
trait as well.

One known issue is that `#[derive(HasField)]` doesn't play alone with
`#[pin_data]` at the moment, for example:

    #[derive(HasField)]
    #[pin_data]
    struct Foo { .. }

works, but 

    #[pin_data]
    #[derive(HasField)]
    struct Foo { .. }

doesn't. Maybe it's by design or maybe something could be improved by
pin-init.


The patchset is based on today's rust/rust-next, top commit is:

	a7c013f77953 ('Merge patch series "refactor Rust proc macros with `syn`"')

Regards,
Boqun

Boqun Feng (7):
  rust: types: Introduce HasField trait and derive macro
  rust: time: hrtimer: Make `HasField` a super-trait of `HasHrTimer`
  rust: workqueue: Add HasField support for Work
  drivers: android: binder: Replace `impl_has_work!` with
    `#[derive(HasField)]`
  rust: sync: Completion: Replace `impl_has_work!` with
    `#[derive(HasField)]`
  rust: work: Remove `impl_has_work!`
  rust: sync: rcu: Introduce RcuHead

 drivers/android/binder/process.rs |   6 +-
 rust/kernel/field.rs              |  73 ++++++++++++++++++++
 rust/kernel/lib.rs                |   1 +
 rust/kernel/prelude.rs            |   4 +-
 rust/kernel/sync/completion.rs    |   8 +--
 rust/kernel/sync/rcu.rs           |  69 ++++++++++++++++++-
 rust/kernel/time/hrtimer.rs       |  70 ++++---------------
 rust/kernel/workqueue.rs          | 109 +++++++++++-------------------
 rust/macros/field.rs              |  85 +++++++++++++++++++++++
 rust/macros/lib.rs                |  11 +++
 10 files changed, 299 insertions(+), 137 deletions(-)
 create mode 100644 rust/kernel/field.rs
 create mode 100644 rust/macros/field.rs

-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-02-27 15:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 21:53 [RFC PATCH 0/7] Introduce HasField infrastructure Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 1/7] rust: types: Introduce HasField trait and derive macro Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 2/7] rust: time: hrtimer: Make `HasField` a super-trait of `HasHrTimer` Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 3/7] rust: workqueue: Add HasField support for Work Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 4/7] drivers: android: binder: Replace `impl_has_work!` with `#[derive(HasField)]` Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 5/7] rust: sync: Completion: " Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 6/7] rust: work: Remove `impl_has_work!` Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 7/7] rust: sync: rcu: Introduce RcuHead Boqun Feng
2026-02-04 14:20 ` [RFC PATCH 0/7] Introduce HasField infrastructure Gary Guo
2026-02-05 20:47   ` Boqun Feng
2026-02-17  1:21 ` Joel Fernandes
2026-02-27 15:00   ` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox