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: <1b9e8761-b71f-4015-bf7d-29072b02f2ac@app.fastmail.com>
Date: Tue, 29 Apr 2025 18:11:02 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Boqun Feng" <boqun.feng@...il.com>,
 "FUJITA Tomonori" <fujita.tomonori@...il.com>,
 "Andreas Hindborg" <a.hindborg@...nel.org>
Cc: rust-for-linux@...r.kernel.org, "Gary Guo" <gary@...yguo.net>,
 "Alice Ryhl" <aliceryhl@...gle.com>, me@...enk.dev,
 daniel.almeida@...labora.com, linux-kernel@...r.kernel.org,
 Netdev <netdev@...r.kernel.org>, "Andrew Lunn" <andrew@...n.ch>,
 "Heiner Kallweit" <hkallweit1@...il.com>,
 "Trevor Gross" <tmgross@...ch.edu>, "Miguel Ojeda" <ojeda@...nel.org>,
 "Alex Gaynor" <alex.gaynor@...il.com>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>,
 "Benno Lossin" <benno.lossin@...ton.me>,
 "Andreas Hindborg" <a.hindborg@...sung.com>,
 "Anna-Maria Gleixner" <anna-maria@...utronix.de>,
 "Frederic Weisbecker" <frederic@...nel.org>,
 "Thomas Gleixner" <tglx@...utronix.de>,
 "John Stultz" <jstultz@...gle.com>, "Stephen Boyd" <sboyd@...nel.org>,
 "Ingo Molnar" <mingo@...hat.com>,
 "Peter Zijlstra" <peterz@...radead.org>,
 "Juri Lelli" <juri.lelli@...hat.com>,
 "Vincent Guittot" <vincent.guittot@...aro.org>,
 "Dietmar Eggemann" <dietmar.eggemann@....com>,
 "Steven Rostedt" <rostedt@...dmis.org>,
 "Benjamin Segall" <bsegall@...gle.com>, "Mel Gorman" <mgorman@...e.de>,
 "Valentin Schneider" <vschneid@...hat.com>, tgunders@...hat.com,
 david.laight.linux@...il.com, "Paolo Bonzini" <pbonzini@...hat.com>,
 "Jocelyn Falempe" <jfalempe@...hat.com>,
 "Russell King" <linux@...linux.org.uk>,
 "Christian Schrefl" <chrisi.schrefl@...il.com>,
 "Linus Walleij" <linus.walleij@...aro.org>
Subject: Re: [PATCH v15 5/6] rust: time: Add wrapper for fsleep() function

On Tue, Apr 29, 2025, at 18:03, Boqun Feng wrote:
> On Tue, Apr 29, 2025, at 8:51 AM, Arnd Bergmann wrote:
>> On Tue, Apr 29, 2025, at 15:17, FUJITA Tomonori wrote:
>>> On Mon, 28 Apr 2025 20:16:47 +0200 Andreas Hindborg <a.hindborg@...nel.org> wrote:
>>>      /// Return the number of milliseconds in the [`Delta`].
>>>      #[inline]
>>> -    pub const fn as_millis(self) -> i64 {
>>> -        self.as_nanos() / NSEC_PER_MSEC
>>> +    pub fn as_millis(self) -> i64 {
>>> +        math64::div64_s64(self.as_nanos(), NSEC_PER_MSEC)
>>>      }
>>>  }
>>
>> I think simply calling ktime_to_ms()/ktime_to_us() should result
>> in reasonably efficient code, since the C version is able to
>> convert the constant divisor into a multiply/shift operation.
>>
>
> Well, before we jump into this, I would like to understand why
> this is not optimized with multiply/shift operations on arm in
> Rust code. Ideally all the dividing constants cases should not
> need to call a C function.

I think it's just because nobody has rewritten the
macros from include/asm-generic/div64.h into rust code.

The compiler could do the same transformation, but they
generally just fall back to calling a libgcc function.

     Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ