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 46087207A15; Fri, 21 Feb 2025 12:17:31 +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=1740140252; cv=none; b=IQYSDCN7yjZgzzi6Dhm5k1/S5a6xc71Nhtwh6iUHqslVom816sNHI4Xqt+EPcXbjYjQfX2MFSIL3csnuQ2Ih8BC24FPD9k7L9n3RMnT6TQDceDAIsMhAi4Y1twY8QD0AQ0QxOmdYd04tBcTwVHWCrGCtv3L5uy7N9VEKzpQvSYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740140252; c=relaxed/simple; bh=+wzFFw1THANHueG/2oJHJC/Y9M9X02s9gVTYFzS0Vvo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=EPvpxU2bpFUXJvW0XRTRA65IliVhaXpq33kn5JSn0QumIsQCPFdbjZGRH8db5Y6QPPIDXU63P62KO4ZC/34CDCM/+oPyXjqxy+mwrJVkgj5gNuvWiVV9y0ypxWb8oHYttydzqJb5vSjW+mNlngzWDjX4xFYx/vVKMTZYJxZ9lxM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sViiXE1c; 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="sViiXE1c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39CB4C4CED6; Fri, 21 Feb 2025 12:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740140251; bh=+wzFFw1THANHueG/2oJHJC/Y9M9X02s9gVTYFzS0Vvo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=sViiXE1cISXk6aPSsd0k3bxlJnN1pK10kqs3Kroe5XXSGPEF/ykyK9gNiX2+dZwbi nowjOXnlM6ES7qRaVGpTc+MOzDPZbt9pjYJJapEFNgQ4n76JnWqcNLd2ienOnsEQNG /gdH46oaRne8z71CFNVokSgfKRhWBzduE+K3VMDDWnBUB8IK1pDTHwUn5cYa1V4dlT h8k3XfWsncfhIEqk8+5+OQIXawdcYldFTnljkU6yT3sBfvoCx9BNAvy4e9uRW9x0hx LkKOgOlgYT9qNtKIywy1YJ9gTH95aJ3jA0yWinWOhHHnVI0yfId5HJO+7SkQz5t8GH Vpet5C47xCTCQ== From: Andreas Hindborg To: "Benno Lossin" Cc: "Miguel Ojeda" , "Anna-Maria Behnsen" , "Frederic Weisbecker" , "Thomas Gleixner" , "Danilo Krummrich" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?Q?Bj?= =?utf-8?Q?=C3=B6rn?= Roy Baron , "Alice Ryhl" , "Trevor Gross" , "Lyude Paul" , "Guangbo Cui" <2407018371@qq.com>, "Dirk Behme" , "Daniel Almeida" , "Tamir Duberstein" , , Subject: Re: [PATCH v8 02/14] rust: hrtimer: introduce hrtimer support In-Reply-To: <841150db-2f92-4cfe-bb1f-29b34b4662c1@proton.me> (Benno Lossin's message of "Fri, 21 Feb 2025 11:05:49 +0000") References: <20250218-hrtimer-v3-v6-12-rc2-v8-0-48dedb015eb3@kernel.org> <20250218-hrtimer-v3-v6-12-rc2-v8-2-48dedb015eb3@kernel.org> <1id7is_U22yzuGODgkUIoB5AFM6snF9CPu7F_sY7Mfkn3EwQRPfjB5JNkRFYu6DX1N8X_OQvdEB2BT-l3rFhwg==@protonmail.internalid> <87a5afhdq0.fsf@kernel.org> <875xl3fvtm.fsf@kernel.org> <841150db-2f92-4cfe-bb1f-29b34b4662c1@proton.me> User-Agent: mu4e 1.12.7; emacs 29.4 Date: Fri, 21 Feb 2025 13:17:17 +0100 Message-ID: <87o6yveble.fsf@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 "Benno Lossin" writes: > On 21.02.25 11:15, Andreas Hindborg wrote: >> Andreas Hindborg writes: >> >>> "Benno Lossin" writes: >>> >>>> On 18.02.25 14:27, Andreas Hindborg wrote: >>>>> +pub trait HrTimerCallback { >>>>> + /// The type whose [`RawHrTimerCallback::run`] method will be invoked when >>>>> + /// the timer expires. >>>>> + type CallbackTarget<'a>: RawHrTimerCallback; >>>>> + >>>>> + /// This type is passed to the timer callback function. It may be a borrow >>>>> + /// of [`Self::CallbackTarget`], or it may be `Self::CallbackTarget` if the >>>>> + /// implementation can guarantee exclusive access to the target during timer >>>> >>>> Technically "exclusive" access is correct if the `CallbackTarget` is >>>> `Pin<&Self>`, since you will get exclusive access to a `Pin<&Self>`, but >>>> it might confuse people, because there can be multiple `Pin<&Self>`. So >>>> I would just drop the word "exclusive" here. >>> >>> Yes, maybe it should be "shared or exclusive access, depending on the type"? >>> >>>> >>>>> + /// handler execution. >>>>> + type CallbackTargetParameter<'a>; >>>> >>>> Also why can't this type be an associated type of `HrTimerPointer`? >>>> Since this seems to always be constrained in the impls of >>>> `RawHrTimerCallback`. >>> >>> That might be a nice improvement, I'll try that out. >> >> Looking closer at this, I don't see how to achieve this. We need access >> to the type here, because it is used in the signature of `run`. >> `HrTimerCallback` has no bounds on it, and that is nice. If we want to >> move these associated types, we have to introduce a bound here. >> >> We need to be generic over the type of the parameter to `run`, and by >> the time the user implements this trait, the type must be known and so >> the user has to specify somehow. > > I think if you put the associated type on the `RawHrTimerCallback` > trait, it should work. What would be the signature of `HrTimerCallback::run` in that case? Best regards, Andreas Hindborg