Re: [PATCH v1] rust: time: make ClockSource unsafe trait
From: Andreas Hindborg
Date: Wed Jul 02 2025 - 04:38:53 EST
"FUJITA Tomonori" <fujita.tomonori@xxxxxxxxx> writes:
> On Mon, 30 Jun 2025 15:33:31 +0200
> Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
>> 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>
>
> Thanks!
>
>> Though you're missing `` around [0; KTIME_MAX] in some places, which
>> may be worth adding.
>
> Andreas, would you like me to send v2 with the above changes?
I can add the ticks.
Best regards,
Andreas Hindborg