[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87lds3cjgx.fsf@kernel.org>
Date: Mon, 14 Apr 2025 09:04:14 +0200
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Boqun Feng" <boqun.feng@...il.com>
Cc: "FUJITA Tomonori" <fujita.tomonori@...il.com>,
<rust-for-linux@...r.kernel.org>, "Gary Guo" <gary@...yguo.net>, "Fiona
Behrens" <me@...enk.dev>, "Daniel Almeida"
<daniel.almeida@...labora.com>, <linux-kernel@...r.kernel.org>,
<netdev@...r.kernel.org>, <andrew@...n.ch>, <hkallweit1@...il.com>,
<tmgross@...ch.edu>, <ojeda@...nel.org>, <alex.gaynor@...il.com>,
<bjorn3_gh@...tonmail.com>, <benno.lossin@...ton.me>,
<a.hindborg@...sung.com>, <aliceryhl@...gle.com>,
<anna-maria@...utronix.de>, <frederic@...nel.org>,
<tglx@...utronix.de>, <arnd@...db.de>, <jstultz@...gle.com>,
<sboyd@...nel.org>, <mingo@...hat.com>, <peterz@...radead.org>,
<juri.lelli@...hat.com>, <vincent.guittot@...aro.org>,
<dietmar.eggemann@....com>, <rostedt@...dmis.org>,
<bsegall@...gle.com>, <mgorman@...e.de>, <vschneid@...hat.com>,
<tgunders@...hat.com>, <david.laight.linux@...il.com>
Subject: Re: [PATCH v13 3/5] rust: time: Introduce Instant type
"Boqun Feng" <boqun.feng@...il.com> writes:
> On Sun, Apr 13, 2025 at 07:43:08PM +0900, FUJITA Tomonori wrote:
>> Introduce a type representing a specific point in time. We could use
>> the Ktime type but C's ktime_t is used for both timestamp and
>> timedelta. To avoid confusion, introduce a new Instant type for
>> timestamp.
>>
>> Rename Ktime to Instant and modify their methods for timestamp.
>>
>> Implement the subtraction operator for Instant:
>>
>> Delta = Instant A - Instant B
>>
>> Reviewed-by: Boqun Feng <boqun.feng@...il.com>
>
> I probably need to drop my Reviewed-by because of something below:
>
>> Reviewed-by: Gary Guo <gary@...yguo.net>
>> Reviewed-by: Fiona Behrens <me@...enk.dev>
>> Tested-by: Daniel Almeida <daniel.almeida@...labora.com>
>> Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>
>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@...il.com>
>> ---
> [...]
>> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
>> index ce53f8579d18..27243eaaf8ed 100644
>> --- a/rust/kernel/time/hrtimer.rs
>> +++ b/rust/kernel/time/hrtimer.rs
>> @@ -68,7 +68,7 @@
>> //! `start` operation.
>>
>> use super::ClockId;
>> -use crate::{prelude::*, time::Ktime, types::Opaque};
>> +use crate::{prelude::*, time::Instant, types::Opaque};
>> use core::marker::PhantomData;
>> use pin_init::PinInit;
>>
>> @@ -189,7 +189,7 @@ pub trait HrTimerPointer: Sync + Sized {
>>
>> /// Start the timer with expiry after `expires` time units. If the timer was
>> /// already running, it is restarted with the new expiry time.
>> - fn start(self, expires: Ktime) -> Self::TimerHandle;
>> + fn start(self, expires: Instant) -> Self::TimerHandle;
>
> We should be able to use what I suggested:
>
> https://lore.kernel.org/rust-for-linux/Z_ALZsnwN53ZPBrB@boqun-archlinux/
>
> to make different timer modes (rel or abs) choose different expire type.
>
> I don't think we can merge this patch as it is, unfortunately, because
> it doesn't make sense for a relative timer to take an Instant as expires
> value.
I told Tomo he could use `Instant` in this location and either he or I
would fix it up later [1].
I don't want to block the series on this since the new API is not worse
than the old one where Ktime is overloaded for both uses.
Best regards,
Andreas Hindborg
[1] https://lore.kernel.org/all/877c41v7kf.fsf@kernel.org
Powered by blists - more mailing lists