Rust for Linux List
 help / color / mirror / Atom feed
From: Boqun Feng <boqun@kernel.org>
To: FUJITA Tomonori <tomo@flapping.org>
Cc: mike@fireburn.co.uk, a.hindborg@kernel.org,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	ojeda@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
	lossin@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
	dakr@kernel.org, daniel.almeida@collabora.com,
	frederic@kernel.org, tglx@kernel.org, anna-maria@linutronix.de,
	jstultz@google.com, sboyd@kernel.org
Subject: Re: [PATCH 9/9] rust: time: add ktime_get_real_seconds
Date: Fri, 30 Oct 2026 11:59:24 -0700	[thread overview]
Message-ID: <auTpDD4GRiD00jP2@tardis.local> (raw)
In-Reply-To: <20261030.190502.1711453613571853758.tomo@flapping.org>

On Fri, Oct 30, 2026 at 07:05:02PM +0900, FUJITA Tomonori wrote:
> On Fri, 30 Oct 2026 07:57:50 +0000
> Mike Lothian <mike@fireburn.co.uk> wrote:
> 
> > So it's the case you described, Tomonori: the format is fixed outside
> > the kernel, by the dock's firmware, and what the caller wants is an i64
> > of seconds since the epoch.  It never gets subtracted from anything, so a
> > seconds based Instant would only be there to be converted straight back

Even that, I think Instant<Sec> would still be more clear than returning
an i64. Also regarding Tomo's concern:

| So a seconds based `Instant` has to define what `Instant - Instant`
| returns, and `Delta<Sec>` would have no consumer.

We can probably only impl ops::Sub for Instant<C, NSec>, then we don't
have to deal with `Delta<Sec>` until there is a user. (We probably want
to avoid a from_ktime() for Instant<Sec> as well, so separate impl
blocks make sense).

> 
> Right, you only need an i64 of seconds since the epoch and do no
> arithmetic or comparison on it. A type is useful when it guards those
> operations, and there are none here. So the plain function is fine

The way I see it is from kernel::time perspective, we still want to make
sure the APIs are still in the same abstraction layer, a
ktime_get_real_seconds() co-exists with Instant::now() as the public
interface layer breaks that in my opinion. And the generic type
parameter should be flexible enough to avoid introduce anything we don't
have a user yet.

Thoughts?

Regards,
Boqun

> with me. If a caller that needs them shows up later, we can add a type
> then.

  reply	other threads:[~2026-10-30 18:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 16:28 [PATCH 0/9] rust: core abstractions for a USB display driver Mike Lothian
2026-08-26 16:28 ` [PATCH 1/9] rust: sync: completion: add single-shot and timed operations Mike Lothian
2026-08-26 16:28 ` [PATCH 2/9] rust: hrtimer: add ArcHrTimerHandle::restart Mike Lothian
2026-08-27 13:27   ` Andreas Hindborg
     [not found]     ` <3-IkUMhanJhClxwXLNvuF1-ncsHt6uM6GRmW78t81tKgo_5IO80fRJ9HZROE5RwlmxZhufdPXswcExj5j65ejw==@protonmail.internalid>
     [not found]       ` <CAHbf0-F-KNQu5NrFcUw1JOwaVQJq5hS+d9OHTmV3J2Pi+hfOqA@mail.gmail.com>
2026-08-31 16:54         ` Andreas Hindborg
2026-09-02 12:49           ` Mike Lothian
2026-08-26 16:28 ` [PATCH 3/9] rust: random: add a safe get_random_bytes wrapper Mike Lothian
2026-08-26 16:28 ` [PATCH 4/9] rust: xxhash: add a safe xxh64 wrapper Mike Lothian
2026-08-26 16:28 ` [PATCH 5/9] rust: workqueue: make OwnedQueue thread-safe Mike Lothian
2026-08-26 16:28 ` [PATCH 6/9] rust: io: add checked offset copy helpers Mike Lothian
2026-08-26 16:28 ` [PATCH 7/9] rust: hrtimer: expose interrupt state in hard callbacks Mike Lothian
2026-08-27 13:34   ` Andreas Hindborg
2026-08-26 16:28 ` [PATCH 8/9] rust: error: expose EPROTO Mike Lothian
2026-08-26 16:34   ` Miguel Ojeda
2026-08-26 16:28 ` [PATCH 9/9] rust: time: add ktime_get_real_seconds Mike Lothian
2026-08-27 13:39   ` Andreas Hindborg
2026-09-08 11:14     ` FUJITA Tomonori
2026-09-08 13:01       ` Andreas Hindborg
2026-10-30  7:57         ` Mike Lothian
2026-10-30 10:05           ` FUJITA Tomonori
2026-10-30 18:59             ` Boqun Feng [this message]
2026-10-31  0:39               ` FUJITA Tomonori
2026-09-08 11:19   ` FUJITA Tomonori
2026-08-26 16:54 ` [PATCH 0/9] rust: core abstractions for a USB display driver Miguel Ojeda

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=auTpDD4GRiD00jP2@tardis.local \
    --to=boqun@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=bjorn3_gh@protonmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=frederic@kernel.org \
    --cc=gary@garyguo.net \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mike@fireburn.co.uk \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=tomo@flapping.org \
    /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