rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com,
	tmgross@umich.edu, ojeda@kernel.org, alex.gaynor@gmail.com,
	gary@garyguo.net, bjorn3_gh@protonmail.com,
	benno.lossin@proton.me, a.hindborg@samsung.com,
	aliceryhl@google.com, anna-maria@linutronix.de,
	frederic@kernel.org, tglx@linutronix.de, arnd@arndb.de,
	jstultz@google.com, sboyd@kernel.org, mingo@redhat.com,
	peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, tgunders@redhat.com, me@kloenk.dev,
	david.laight.linux@gmail.com
Subject: Re: [PATCH v14 1/6] rust: hrtimer: Add Ktime temporarily
Date: Tue, 22 Apr 2025 07:19:25 -0700	[thread overview]
Message-ID: <aAelbeiWVZgL-kMh@Mac.home> (raw)
In-Reply-To: <20250422135336.194579-2-fujita.tomonori@gmail.com>

On Tue, Apr 22, 2025 at 10:53:30PM +0900, FUJITA Tomonori wrote:
> Add Ktime temporarily until hrtimer is refactored to use Instant and
> Duration types.
> 
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

(Tomo: seems you didn't add me Cced in a few patches, could you add me
Cced for all the patches in the future, thanks!)

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  rust/kernel/time/hrtimer.rs         | 18 +++++++++++++++++-
>  rust/kernel/time/hrtimer/arc.rs     |  2 +-
>  rust/kernel/time/hrtimer/pin.rs     |  2 +-
>  rust/kernel/time/hrtimer/pin_mut.rs |  4 ++--
>  rust/kernel/time/hrtimer/tbox.rs    |  2 +-
>  5 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
> index ce53f8579d18..9fd95f13e53b 100644
> --- a/rust/kernel/time/hrtimer.rs
> +++ b/rust/kernel/time/hrtimer.rs
> @@ -68,10 +68,26 @@
>  //! `start` operation.
>  
>  use super::ClockId;
> -use crate::{prelude::*, time::Ktime, types::Opaque};
> +use crate::{prelude::*, types::Opaque};
>  use core::marker::PhantomData;
>  use pin_init::PinInit;
>  
> +/// A Rust wrapper around a `ktime_t`.
> +// NOTE: Ktime is going to be removed when hrtimer is converted to Instant/Duration.
> +#[repr(transparent)]
> +#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord)]
> +pub struct Ktime {
> +    inner: bindings::ktime_t,
> +}
> +
> +impl Ktime {
> +    /// Returns the number of nanoseconds.
> +    #[inline]
> +    pub fn to_ns(self) -> i64 {
> +        self.inner
> +    }
> +}
> +
>  /// A timer backed by a C `struct hrtimer`.
>  ///
>  /// # Invariants
> diff --git a/rust/kernel/time/hrtimer/arc.rs b/rust/kernel/time/hrtimer/arc.rs
> index 4a984d85b4a1..ccf1e66e5b2d 100644
> --- a/rust/kernel/time/hrtimer/arc.rs
> +++ b/rust/kernel/time/hrtimer/arc.rs
> @@ -5,10 +5,10 @@
>  use super::HrTimerCallback;
>  use super::HrTimerHandle;
>  use super::HrTimerPointer;
> +use super::Ktime;
>  use super::RawHrTimerCallback;
>  use crate::sync::Arc;
>  use crate::sync::ArcBorrow;
> -use crate::time::Ktime;
>  
>  /// A handle for an `Arc<HasHrTimer<T>>` returned by a call to
>  /// [`HrTimerPointer::start`].
> diff --git a/rust/kernel/time/hrtimer/pin.rs b/rust/kernel/time/hrtimer/pin.rs
> index f760db265c7b..293ca9cf058c 100644
> --- a/rust/kernel/time/hrtimer/pin.rs
> +++ b/rust/kernel/time/hrtimer/pin.rs
> @@ -4,9 +4,9 @@
>  use super::HrTimer;
>  use super::HrTimerCallback;
>  use super::HrTimerHandle;
> +use super::Ktime;
>  use super::RawHrTimerCallback;
>  use super::UnsafeHrTimerPointer;
> -use crate::time::Ktime;
>  use core::pin::Pin;
>  
>  /// A handle for a `Pin<&HasHrTimer>`. When the handle exists, the timer might be
> diff --git a/rust/kernel/time/hrtimer/pin_mut.rs b/rust/kernel/time/hrtimer/pin_mut.rs
> index 90c0351d62e4..6033572d35ad 100644
> --- a/rust/kernel/time/hrtimer/pin_mut.rs
> +++ b/rust/kernel/time/hrtimer/pin_mut.rs
> @@ -1,9 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>  
>  use super::{
> -    HasHrTimer, HrTimer, HrTimerCallback, HrTimerHandle, RawHrTimerCallback, UnsafeHrTimerPointer,
> +    HasHrTimer, HrTimer, HrTimerCallback, HrTimerHandle, Ktime, RawHrTimerCallback,
> +    UnsafeHrTimerPointer,
>  };
> -use crate::time::Ktime;
>  use core::{marker::PhantomData, pin::Pin, ptr::NonNull};
>  
>  /// A handle for a `Pin<&mut HasHrTimer>`. When the handle exists, the timer might
> diff --git a/rust/kernel/time/hrtimer/tbox.rs b/rust/kernel/time/hrtimer/tbox.rs
> index 2071cae07234..29526a5da203 100644
> --- a/rust/kernel/time/hrtimer/tbox.rs
> +++ b/rust/kernel/time/hrtimer/tbox.rs
> @@ -5,9 +5,9 @@
>  use super::HrTimerCallback;
>  use super::HrTimerHandle;
>  use super::HrTimerPointer;
> +use super::Ktime;
>  use super::RawHrTimerCallback;
>  use crate::prelude::*;
> -use crate::time::Ktime;
>  use core::ptr::NonNull;
>  
>  /// A handle for a [`Box<HasHrTimer<T>>`] returned by a call to
> -- 
> 2.43.0
> 
> 

  reply	other threads:[~2025-04-22 14:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 13:53 [PATCH v14 0/6] rust: Add IO polling FUJITA Tomonori
2025-04-22 13:53 ` [PATCH v14 1/6] rust: hrtimer: Add Ktime temporarily FUJITA Tomonori
2025-04-22 14:19   ` Boqun Feng [this message]
2025-04-22 14:31     ` FUJITA Tomonori
2025-04-23  8:34       ` Andreas Hindborg
2025-04-23  9:26   ` Andreas Hindborg
2025-04-22 13:53 ` [PATCH v14 2/6] rust: time: Add PartialEq/Eq/PartialOrd/Ord trait to Ktime FUJITA Tomonori
2025-04-22 13:53 ` [PATCH v14 3/6] rust: time: Introduce Delta type FUJITA Tomonori
2025-04-22 13:53 ` [PATCH v14 4/6] rust: time: Introduce Instant type FUJITA Tomonori
2025-04-22 13:53 ` [PATCH v14 5/6] rust: time: Add wrapper for fsleep() function FUJITA Tomonori
2025-04-22 13:53 ` [PATCH v14 6/6] MAINTAINERS: rust: Add a new section for all of the time stuff FUJITA Tomonori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aAelbeiWVZgL-kMh@Mac.home \
    --to=boqun.feng@gmail.com \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=andrew@lunn.ch \
    --cc=anna-maria@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=bsegall@google.com \
    --cc=david.laight.linux@gmail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=frederic@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=hkallweit1@gmail.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kloenk.dev \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tgunders@redhat.com \
    --cc=tmgross@umich.edu \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).