From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD89E2D6E75 for ; Wed, 28 Jan 2026 23:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769644517; cv=none; b=G+O4aFDSvQqpDOJ4jnzdKCdMwQuIYk8OMAgMguNBoH4u+4WKbfqDZTC15RdGFCYrAKW7S35P4YmEaORIko1LSwXEbjddQc7/Rog6ea7oCvP14rWz4dgm/VrAgKH3V+ivGLq3G5kPMzRINt6caKUcSxMPD/hlsTBKNWjzzYLJ7ec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769644517; c=relaxed/simple; bh=sxpbpWKTZvxcwwFtu3C/YF5qkG3yECiILa4gEgaG3GA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KG6b3zoo4BtoY536wy3k7YM66NpuarldPvKFBfrFXnj8FQp/QRsolV60cNmsg6iV+f9aBtVETdPQqBY0NFeLMtmDjXWPCqWwGpnhPIARA90EuvxkJGNSJAvPMGrLKkXOOi7kZAd3vLKWsQiF9H0CSckA6elF88bxHMfMRAEbx9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MLe4mcSd; arc=none smtp.client-ip=209.85.221.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MLe4mcSd" Received: by mail-vk1-f175.google.com with SMTP id 71dfb90a1353d-566390e7db3so296893e0c.1 for ; Wed, 28 Jan 2026 15:55:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769644515; x=1770249315; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:feedback-id:from:to:cc:subject:date:message-id:reply-to; bh=9rsltUJYSM7HaaCYyAzd6NhR6FQ1Y8lMhd5oHE/Kxmw=; b=MLe4mcSd3+Hd4sYZ2XPLy4bB40qriDMweOSeXSPXQzDXX4e6QVtjEbYe9LZGDgBtwr wN8T7FWPbyn7BE504w/DK+T/lTU4DQ9dv3wrDqY19YPQz9+HKWUsGBf64ZNqhHAvVal2 I7DXEXr4RpgScQg8caTZAzDeJauSXJBH0qLKHzpm7lwK3RyrRF/0+zeL8Qgo2dHCaAzS mzHseKd7pj+8RerQ1JEjc820TYgrtHk/Ji4AXrhhdeORj2KHxyAht7O3GFnCc1zCpPFC Wqz1j/4sc4EVad4zPS9HDszmygmTVv3r55D54W6u1s4PNznqjayv5sqsBWTQ8kDUFW5d YVTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769644515; x=1770249315; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:feedback-id:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=9rsltUJYSM7HaaCYyAzd6NhR6FQ1Y8lMhd5oHE/Kxmw=; b=pyJCnuEoc4jbJjL6vUISgMIcn17ac7AiV0aOH8nui1C7+ajVlKkkzjotnSVNnTZwUF wRNFakoe8lVMhQdaPVvofj09Kn025wa7JnrLyHqIIQQ4EzHHmc5YwbYd4Mwt1tSCfrem jMZSYw9rSdeP1hq6FNaXdcGExcAOIKcOcE0i4y3WMQRQQ8LLxL5C24MHn6QtMuKIbCfW 9LdXf9LK4/7uP9IMGONqE7NSchvrWRcmaf/fuepb9I2z7Txw2UGuzQwpUhVfdOeTfVXt Ar7VuqDwTKHQqkh4sTzY34zK+eXiQRL0e2JBZk3sLI4IHdXKZWrXbYsdPHkBLP724lXn bhYA== X-Gm-Message-State: AOJu0YwP4/KLNUId3J7lvnYXa5XIG4IVmYRILE2dtLzE+9AFjOy6IPuR KlKcx8kgoTURiemYIvzMGvvePJhG1shmxKzCIhZhAjcMtkmsMd5CMCFJUZ+5Sg== X-Gm-Gg: AZuq6aLOkaaj8387LSuHPO+OfUsLtLUqGZ/j3fEI9EGD2JxvhavIgQ0pktCFX3TDHRR dvutacwLtoXVaL7F/Gy1drSNc+CvWSQatWFAucuhRiF5/knd2UmcVa+LpfhPnSswlrkNTr6+YBz Bi2FNyu9jqgOZru9icY9Etu89cvip3RM7jiBtNhjhpOdM3iYTdNVuJIdz8RAu63wEM/LGu72zQq mqCjneVp6pBmx3jShrY8OIzOV2x9PQu+S2KmVBKXZx9oolJZ4zaqW+gRCgpQHueM0osJRcmxXhN WBum2F0V3zVvPxzt1ninvSykp6eZMfIL2mcxe3TriXOob7kbQB+FmWUXasXPHk1f9wRTfkqFH9N YBPXn4kAUisd+2T7PWPL7iQnr2+ElVCOp6x3LpHw5ooGBe+l4k2gedhOJYL+KHchmnZzJZhsrR+ Gz30pf5+4HFSAcZH87t/s4q98SNumdw4ZWjm9CkwBcjTRIO9Ku0GGa/q+EeSe08lrv5CJqqIR6F IdzxNrGDoDkNkQbYXa4Qv/ipA== X-Received: by 2002:a05:6214:1247:b0:880:5867:45b4 with SMTP id 6a1803df08f44-894cc7b9952mr92925456d6.13.1769637214740; Wed, 28 Jan 2026 13:53:34 -0800 (PST) Received: from fauth-a1-smtp.messagingengine.com (fauth-a1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c711d2889asm258472585a.27.2026.01.28.13.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jan 2026 13:53:34 -0800 (PST) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id 1652AF4006C; Wed, 28 Jan 2026 16:53:33 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 28 Jan 2026 16:53:33 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduieeggeehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepuehoqhhunhcuhfgv nhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtthgvrh hnpefgteffhfehjeegtdduieffudetfeehgfegudejudfhieefgfeigfevueduleduffen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquh hnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedqudej jeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrd hnrghmvgdpnhgspghrtghpthhtohepgedvpdhmohguvgepshhmthhpohhuthdprhgtphht thhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtph htthhopehruhhsthdqfhhorhdqlhhinhhugiesvhhgvghrrdhkvghrnhgvlhdrohhrghdp rhgtphhtthhopehrtghusehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepgh hrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhgpdhrtghpthhtoheprghr vhgvsegrnhgurhhoihgurdgtohhmpdhrtghpthhtohepthhkjhhoshesrghnughrohhiug drtghomhdprhgtphhtthhopegsrhgruhhnvghrsehkvghrnhgvlhdrohhrghdprhgtphht thhopegtmhhllhgrmhgrshesghhoohhglhgvrdgtohhmpdhrtghpthhtoheprghlihgtvg hrhihhlhesghhoohhglhgvrdgtohhm X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jan 2026 16:53:32 -0500 (EST) From: Boqun Feng To: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, rcu@vger.kernel.org Cc: Greg Kroah-Hartman , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , 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 , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [RFC PATCH 0/7] Introduce HasField infrastructure Date: Wed, 28 Jan 2026 13:53:23 -0800 Message-ID: <20260128215330.58410-1-boqun.feng@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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)