From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC78829A1; Tue, 17 Feb 2026 20:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771361773; cv=none; b=fILeJPBlQ2FJyaywnmaQ1703gq5yjAAjyZzymAuOcQeSJ0n5TrkE5/13zz7bQ4we0j199qCTjwbmQt5+WWwhlZzmxcfLpDlUUFxmmgPfE4FeCHAj2EaxGvcPKritGSsgGwsikTMFSJ3RE9qQmjgfnfrt2qdZ1fQ6Jb7LI6U/sXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771361773; c=relaxed/simple; bh=rEdYMtc/LMDSmu4lqroltT9WgSaqkm/x/KUtWWsA4w8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SNK+krPNgU4MbNrJQZfZRnKPx73t5vAiE5fRlBfejnG9zKN/EebY8xKR2yzDlSwiVUsSCMRWsqzVwF8wrlruDSFBDr2pCdcl4ou2cdSzDZkFURzD9L3jjaHwv8ONUpYRnnRdPdUh+OULDz9dUJnYyZZraUoJwdfdN/a9io8adf4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V0T80UVm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V0T80UVm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 626E9C2BC86; Tue, 17 Feb 2026 20:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771361773; bh=rEdYMtc/LMDSmu4lqroltT9WgSaqkm/x/KUtWWsA4w8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V0T80UVmspe/iZ22Ti+mUBk58028KD8QykxmyguzW/7aDR4j+TCBqEq/NoaCIpvi/ VTGTFedmNXqN9aCyHz4hf2A8T2zil3KUXxF3fwbtV88tu3FEcuuMnScZlVxSRxfekV hPCDU52oe0mc0KzJ21EFoiJhZSRtrAW0Jibj+VNKLdDWJOBOdGangDGXWax8arWcNj h9uwpFER1MKvDFnQ07kUoVhE/8hhtciUTkeWnR3YRnUN+iXTew/XW5yxutf+gdY1vZ 3cFIhLRSLwol6/7ilBqaCCfg20Nhwi8K2cBp0Mp/FPmiIPnOXrInSHMoC9poEZ4hq0 X0KsoUW2XJRXg== Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfauth.phl.internal (Postfix) with ESMTP id 6D023F40068; Tue, 17 Feb 2026 15:56:11 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 17 Feb 2026 15:56:11 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvvddtjeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunheskhgvrhhnvghlrdhorhhgqeenucggtffrrghtthgvrhhnpe ekgffhhfeuheelhfekteeuffejveetjeefffettedtteegfefftdduteduudfgleenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnod hmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduieejtdelkeegjeduqddujeej keehheehvddqsghoqhhunheppehkvghrnhgvlhdrohhrghesfhhigihmvgdrnhgrmhgvpd hnsggprhgtphhtthhopeduledpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprgdr hhhinhgusghorhhgsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegsohhquhhnrdhfvg hnghesghhmrghilhdrtghomhdprhgtphhtthhopehfuhhjihhtrgdrthhomhhonhhorhhi sehgmhgrihhlrdgtohhmpdhrtghpthhtohepfhhrvgguvghrihgtsehkvghrnhgvlhdroh hrghdprhgtphhtthhopehlhihuuggvsehrvgguhhgrthdrtghomhdprhgtphhtthhopeht ghhlgieskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghnnhgrqdhmrghrihgrsehlih hnuhhtrhhonhhigidruggvpdhrtghpthhtohepjhhsthhulhhtiiesghhoohhglhgvrdgt ohhmpdhrtghpthhtohepshgsohihugeskhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i8dbe485b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 Feb 2026 15:56:10 -0500 (EST) Date: Tue, 17 Feb 2026 12:56:09 -0800 From: Boqun Feng To: Andreas Hindborg Cc: Boqun Feng , FUJITA Tomonori , Frederic Weisbecker , Lyude Paul , Thomas Gleixner , Anna-Maria Behnsen , John Stultz , Stephen Boyd , Miguel Ojeda , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Alice Ryhl , Trevor Gross , Danilo Krummrich , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rust: hrtimer: document handle based design rationale Message-ID: References: <20260215-hrtimer-docs-v1-1-bff6a6c0d923@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260215-hrtimer-docs-v1-1-bff6a6c0d923@kernel.org> On Sun, Feb 15, 2026 at 09:36:04PM +0100, Andreas Hindborg wrote: > Add implementation notes explaining why the hrtimer abstraction uses a > handle based approach. > > Signed-off-by: Andreas Hindborg Thanks for adding this! Reviewed-by: Boqun Feng However I feel these are not just implementation details. They are the design decision we made because of the limitation you mentioned. Maybe make them "//!" doc comment and just put them as a separate section that describes the necessity of handles? Thoughts? Regards, Boqun > --- > rust/kernel/time/hrtimer.rs | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs > index 856d2d929a008..f92880b2cbdbd 100644 > --- a/rust/kernel/time/hrtimer.rs > +++ b/rust/kernel/time/hrtimer.rs > @@ -67,6 +67,18 @@ > //! A `restart` operation on a timer in the **stopped** state is equivalent to a > //! `start` operation. > > +// Implementation details > +// > +// The reasoning for adopting a handle based approach: > +// - If we explicitly drop the target of a timer callback in the timer callback, we > +// may get a dangling reference. > +// - If the callback owns the last reference to the target, target may be dropped > +// in non-sleepable context when the callback is finished. > +// - When dropping an object that is the target of an armed timer, we may drop > +// fields accessed by the timer callback before we cancel the timer (drop order). > +// > +// By using a handle, we can make the handle own the callback target and avoid these problems. > + > use super::{ClockSource, Delta, Instant}; > use crate::{prelude::*, types::Opaque}; > use core::{marker::PhantomData, ptr::NonNull}; > > --- > base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b > change-id: 20260215-hrtimer-docs-52ec9c020285 > > Best regards, > -- > Andreas Hindborg > >