Re: [PATCH v1 1/2] hrtimer: Add hrtimer_forward_safe_from_callback()

From: Thomas Gleixner

Date: Mon Nov 09 2026 - 16:16:02 EST


On Mon, Nov 02 2026 at 08:28, FUJITA Tomonori wrote:
> From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
>
> A hrtimer can be started while its callback runs. hrtimer_forward()
> writes the expiry without the base lock, so the caller has to serialize
> it against a concurrent hrtimer_start(). Otherwise the write can change
> the sort key of a queued timer.
>
> Add a variant which does the check and the update with the base lock
> held. If the timer is already queued, the expiry is left alone and the
> expiry set by hrtimer_start() wins.
>
> The first user is the Rust hrtimer abstraction. Safe Rust code can
> start a timer while its callback runs, so forward() in the callback
> can only be a safe API if the core handles a concurrent start.
>
> Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/877bk3ixp5.ffs@fw13/
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>

I don't have anything conflicting at the moment, so this can go through
the rust tree.

Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxx>