[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLghps=Aa69Aye5PCGu6LuoHomMcQYEN1USTd5JiBkLdJLQ@mail.gmail.com>
Date: Mon, 7 Oct 2024 16:24:28 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: anna-maria@...utronix.de, frederic@...nel.org, tglx@...utronix.de,
miguel.ojeda.sandonis@...il.com, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, andrew@...n.ch, hkallweit1@...il.com,
tmgross@...ch.edu, ojeda@...nel.org, alex.gaynor@...il.com, gary@...yguo.net,
bjorn3_gh@...tonmail.com, benno.lossin@...ton.me, a.hindborg@...sung.com,
arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 3/6] rust: time: Implement addition of Ktime
and Delta
On Mon, Oct 7, 2024 at 8:17 AM FUJITA Tomonori
<fujita.tomonori@...il.com> wrote:
>
> On Sat, 5 Oct 2024 20:36:44 +0200
> Miguel Ojeda <miguel.ojeda.sandonis@...il.com> wrote:
>
> > On Sat, Oct 5, 2024 at 2:26 PM FUJITA Tomonori
> > <fujita.tomonori@...il.com> 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?
We already do that in the existing code. The Ktime::sub method touches
the ktime_t directly and performs a subtraction using the - operator
rather than call a ktime_ method for it.
Alice
Powered by blists - more mailing lists