lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251116093805.7918b83d@nimda.home>
Date: Sun, 16 Nov 2025 09:38:05 +0300
From: Onur Özkan <work@...rozkan.dev>
To: Lyude Paul <lyude@...hat.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org, Andreas
 Hindborg <a.hindborg@...nel.org>, Boqun Feng <boqun.feng@...il.com>, FUJITA
 Tomonori <fujita.tomonori@...il.com>, Frederic Weisbecker
 <frederic@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, Anna-Maria
 Behnsen <anna-maria@...utronix.de>, John Stultz <jstultz@...gle.com>,
 Stephen Boyd <sboyd@...nel.org>, Miguel Ojeda <ojeda@...nel.org>, Alex
 Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin
 <lossin@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross
 <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>
Subject: Re: [PATCH] rust/time: Add Delta::from_nanos()

On Fri, 14 Nov 2025 13:42:06 -0500
Lyude Paul <lyude@...hat.com> wrote:

> Since rvkms is going to need to create its own Delta instances, and we
> already have functions for creating Delta with every other unit of
> time.
> 
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> ---
>  rust/kernel/time.rs | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
> index 6ea98dfcd0278..2b096e5a61cda 100644
> --- a/rust/kernel/time.rs
> +++ b/rust/kernel/time.rs
> @@ -363,6 +363,12 @@ impl Delta {
>      /// A span of time equal to zero.
>      pub const ZERO: Self = Self { nanos: 0 };
>  
> +    /// Create a new [`Delta`] from a number of nanoseconds.
> +    #[inline]
> +    pub const fn from_nanos(nanos: i64) -> Self {
> +        Self { nanos }
> +    }
> +

I wonder if it makes sense to remove all the `from_*` functions from
`Delta` and replace them all with something like this:

    pub const fn from_duration(duration: Duration) -> Self {
        Self {
            nanos: duration.as_nanos(),
        }
    }

What do you think?

>      /// Create a new [`Delta`] from a number of microseconds.
>      ///
>      /// The `micros` can range from -9_223_372_036_854_775 to
> 9_223_372_036_854_775.
> 
> base-commit: 5935461b458463ee51aac8d95c25d7a5e1de8c4d


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ