Re: [PATCH net-next v2 3/6] rust: time: Implement addition of Ktime and Delta

From: FUJITA Tomonori
Date: Mon Oct 07 2024 - 02:17:45 EST


On Sat, 5 Oct 2024 20:36:44 +0200
Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote:

> On Sat, Oct 5, 2024 at 2:26 PM FUJITA Tomonori
> <fujita.tomonori@xxxxxxxxx> wrote:
>>
>> + fn add(self, delta: Delta) -> Ktime {
>> + // SAFETY: FFI call.
>> + let t = unsafe { bindings::ktime_add_ns(self.inner, delta.as_nanos() as u64) };
>> + Ktime::from_raw(t)
>> + }
>
> I wonder if we want to use the `ktime` macros/operations for this type
> or not (even if we still promise it is the same type underneath). It
> means having to define helpers, adding `unsafe` code and `SAFETY`
> comments, a call penalty in non-LTO, losing overflow checking (if we
> want it for these types), and so on.

Yeah, if we are allowed to touch ktime_t directly instead of using the
accessors, it's great for the rust side.

The timers maintainers, what do you think?