Re: [PATCH v1] rust: time: make ClockSource unsafe trait

From: Alice Ryhl
Date: Mon Jun 30 2025 - 09:34:04 EST


On Mon, Jun 30, 2025 at 3:10 PM FUJITA Tomonori
<fujita.tomonori@xxxxxxxxx> wrote:
>
> Mark the ClockSource trait as unsafe and document its safety
> requirements. Specifically, implementers must guarantee that their
> `ktime_get()` implementation returns a value in the inclusive range
> [0, KTIME_MAX].
>
> Update all existing implementations to use `unsafe impl` with
> corresponding safety comments.
>
> Note that there could be potential users of a customized clock source [1]
> so we don't seal the trait.
>
> Link: https://lore.kernel.org/rust-for-linux/Z9xb1r1x5tOzAIZT@boqun-archlinux/ [1]
> Suggested-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>

LGTM:
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

Though you're missing `` around [0; KTIME_MAX] in some places, which
may be worth adding.

Alice