[<prev] [next>] [day] [month] [year] [list]
Message-ID: <87bjwg9la4.fsf@kernel.org>
Date: Thu, 09 Jan 2025 14:20:03 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Guangbo Cui" <2407018371@...com>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Anna-Maria Behnsen"
<anna-maria@...utronix.de>, "Frederic Weisbecker" <frederic@...nel.org>,
"Thomas Gleixner" <tglx@...utronix.de>, "Danilo Krummrich"
<dakr@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
"Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Lyude Paul" <lyude@...hat.com>, "Dirk Behme" <dirk.behme@...il.com>,
"Daniel Almeida" <daniel.almeida@...labora.com>,
<rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 05/14] rust: hrtimer: allow timer restart from timer
handler
"Guangbo Cui" <2407018371@...com> writes:
> On Tue, Dec 17, 2024 at 04:17:36PM +0100, Andreas Hindborg wrote:
>> This patch allows timer handlers to report that they want a timer to be
>> restarted after the timer handler has finished executing.
>>
>> Also update the `hrtimer` documentation to showcase the new feature.
>>
>> Signed-off-by: Andreas Hindborg <a.hindborg@...nel.org>
>> ---
>> rust/kernel/time/hrtimer.rs | 37 ++++++++++++++++++++++++++++++++++++-
>> rust/kernel/time/hrtimer/arc.rs | 4 +---
>> 2 files changed, 37 insertions(+), 4 deletions(-)
>>
>> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
>> index 178e33c1f656d2f834e45b004486f6e5fe1813dd..38a8251ea6ba4d84dadad009ed540c150bea4775 100644
>> --- a/rust/kernel/time/hrtimer.rs
>> +++ b/rust/kernel/time/hrtimer.rs
>> @@ -167,7 +167,7 @@ pub trait TimerCallback {
>> type CallbackTargetParameter<'a>;
>>
>> /// Called by the timer logic when the timer fires.
>> - fn run(this: Self::CallbackTargetParameter<'_>)
>> + fn run(this: Self::CallbackTargetParameter<'_>) -> TimerRestart
>> where
>> Self: Sized;
>> }
>> @@ -262,6 +262,41 @@ unsafe fn start(self_ptr: *const Self, expires: Ktime) {
>> }
>> }
>>
>> +/// Restart policy for timers.
>> +pub enum TimerRestart {
>> + /// Timer should not be restarted.
>> + NoRestart,
>> + /// Timer should be restarted.
>> + Restart,
>> +}
>
> If we restart the timer, we may also want to `forward` the timer. I tried
> this series, and wrote some samples, found that it's inconvenient to write
> a loop timer.
>
> This is not a problem, just my feedback on the user experience.
Thanks! Lyude Paul has some patches that adds methods that operate
within timer context, including forwarding. I think they will send them
after this lands.
Best regards,
Andreas Hindborg
Powered by blists - more mailing lists