All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: "FUJITA Tomonori" <fujita.tomonori@gmail.com>
Cc: <rust-for-linux@vger.kernel.org>,  <boqun.feng@gmail.com>,
	<ojeda@kernel.org>,  <alex.gaynor@gmail.com>,  <gary@garyguo.net>,
	<bjorn3_gh@protonmail.com>,  <benno.lossin@proton.me>,
	<aliceryhl@google.com>,  <tmgross@umich.edu>,  <dakr@kernel.org>,
	<frederic@kernel.org>,  <lyude@redhat.com>,  <tglx@linutronix.de>,
	<anna-maria@linutronix.de>,  <jstultz@google.com>,
	 <sboyd@kernel.org>
Subject: Re: [PATCH v1 3/3] rust: time: add ktime_get() to ClockSource trait
Date: Tue, 22 Apr 2025 15:14:46 +0200	[thread overview]
Message-ID: <87ecxk9w3d.fsf@kernel.org> (raw)
In-Reply-To: <20250413105629.162349-4-fujita.tomonori@gmail.com> (FUJITA Tomonori's message of "Sun, 13 Apr 2025 19:56:28 +0900")

"FUJITA Tomonori" <fujita.tomonori@gmail.com> writes:

> Introduce the ktime_get() associated function to the ClockSource
> trait, allowing each clock source to specify how it retrieves the
> current time. This enables Instant::now() to be implemented
> generically using the type-level ClockSource abstraction.
>
> This change enhances the type safety and extensibility of timekeeping
> by statically associating time retrieval mechanisms with their
> respective clock types. It also reduces the reliance on hardcoded
> clock logic within Instant.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
> ---
>  rust/helpers/time.c | 16 ++++++++++++++++
>  rust/kernel/time.rs | 32 ++++++++++++++++++++++++++++----
>  2 files changed, 44 insertions(+), 4 deletions(-)
>
> diff --git a/rust/helpers/time.c b/rust/helpers/time.c
> index 7ae64ad8141d..613475c529d4 100644
> --- a/rust/helpers/time.c
> +++ b/rust/helpers/time.c
> @@ -1,8 +1,24 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/delay.h>
> +#include <linux/timekeeping.h>
>
>  void rust_helper_fsleep(unsigned long usecs)
>  {
>  	fsleep(usecs);
>  }
> +
> +ktime_t rust_helper_ktime_get_real(void)
> +{
> +	return ktime_get_with_offset(TK_OFFS_REAL);
> +}
> +
> +ktime_t rust_helper_ktime_get_boottime(void)
> +{
> +	return ktime_get_with_offset(TK_OFFS_BOOT);
> +}
> +
> +ktime_t rust_helper_ktime_get_clocktai(void)
> +{
> +	return ktime_get_with_offset(TK_OFFS_TAI);
> +}
> diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
> index db9a783631ec..4b9b61eed628 100644
> --- a/rust/kernel/time.rs
> +++ b/rust/kernel/time.rs
> @@ -63,6 +63,11 @@ pub trait ClockSource {
>      ///
>      /// This constant corresponds to the C side `clockid_t` value.
>      const ID: bindings::clockid_t;
> +
> +    /// Get the current time fro the clock source.

Typo fro -> from.


Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>


Best regards,
Andreas Hindborg




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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-13 10:56 [PATCH v1 0/3] rust: time: Introduce typed clock sources and generalize Instant FUJITA Tomonori
2025-04-13 10:56 ` [PATCH v1 1/3] rust: time: replace ClockId enum with ClockSource trait FUJITA Tomonori
2025-04-22 12:51   ` Andreas Hindborg
2025-04-13 10:56 ` [PATCH v1 2/3] rust: time: make Instant generic over ClockSource FUJITA Tomonori
2025-04-22 13:11   ` Andreas Hindborg
2025-04-22 22:12     ` FUJITA Tomonori
2025-04-13 10:56 ` [PATCH v1 3/3] rust: time: add ktime_get() to ClockSource trait FUJITA Tomonori
2025-04-22 13:14   ` Andreas Hindborg [this message]
2025-04-22 22:47     ` 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=87ecxk9w3d.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=frederic@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=jstultz@google.com \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tmgross@umich.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.