Re: [PATCH 2/9] rust: hrtimer: add ArcHrTimerHandle::restart
From: Andreas Hindborg
Date: Thu Aug 27 2026 - 09:34:50 EST
"Mike Lothian" <mike@xxxxxxxxxxxxxx> writes:
> Restarting an already-started timer through the safe API means dropping
> its handle and calling `HrTimerPointer::start()` again. Dropping the
> handle cancels, and cancelling blocks until a running callback returns,
> so this is unavailable to any caller that cannot sleep -- a driver
> re-arming its timer from a callback invoked with interrupts disabled,
> say. Such drivers fall back to the unsafe `HasHrTimer::start()`
> on a raw pointer.
>
> Add `restart()` on the handle. It re-queues the timer in place without
> cancelling first. It is safe because the handle already owns the
> `Arc` that keeps the timer alive and still cancels it on drop, which
> is exactly what `HasHrTimer::start()` requires of its caller.
The intention is that handlers use the `forward` method on the context
object in combination with return value `HrTimerRestart::Restart` to re
arm the timer.
However, we found a data race in the face of concurrent `start`
operations, so we are solving that over at [1].
Best regards,
Andreas Hindborg
[1] https://lore.kernel.org/rust-for-linux/20260825-expires-v2-v1-0-90411c6217c7@xxxxxxxxxx/T/#t