From: Boqun Feng <boqun.feng@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "FUJITA Tomonori" <fujita.tomonori@gmail.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Lyude Paul" <lyude@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Anna-Maria Gleixner" <anna-maria@linutronix.de>,
"John Stultz" <jstultz@google.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Christian Schrefl" <chrisi.schrefl@gmail.com>,
"Russell King" <linux@armlinux.org.uk>
Subject: Re: [PATCH v1] rust: time: Avoid 64-bit integer division
Date: Thu, 1 May 2025 16:03:38 -0700 [thread overview]
Message-ID: <aBP9yvWnB66qJeRh@Mac.home> (raw)
In-Reply-To: <cbbeca76-7a7a-425b-9cdd-8da778b6d8a1@app.fastmail.com>
On Thu, May 01, 2025 at 05:11:44PM +0200, Arnd Bergmann wrote:
> On Thu, May 1, 2025, at 15:20, Boqun Feng wrote:
> > On Thu, May 01, 2025 at 06:12:02AM -0700, Boqun Feng wrote:
> >> On Thu, May 01, 2025 at 10:07:17PM +0900, FUJITA Tomonori wrote:
> >> > On Thu, 1 May 2025 05:26:54 -0700
> >> > Boqun Feng <boqun.feng@gmail.com> wrote:
> >> >
> >> > > On Thu, May 01, 2025 at 10:58:18AM +0900, FUJITA Tomonori wrote:
> >> > >> Avoid 64-bit integer division that 32-bit architectures don't
> >> > >> implement generally. This uses ktime_to_ms() and ktime_to_us()
> >> > >> instead.
> >> > >>
> >> > >> The timer abstraction needs i64 / u32 division so C's div_s64() can be
> >> > >> used but ktime_to_ms() and ktime_to_us() provide a simpler solution
> >> > >> for this timer abstraction problem. On some architectures, there is
> >> > >> room to optimize the implementation of them, but such optimization can
> >> > >> be done if and when it becomes necessary.
> >> > >>
> >> > >
> >> > > Nacked-by: Boqun Feng <boqun.feng@gmail.com>
> >> > >
> >> > > As I said a few times, we should rely on compiler's optimization when
> >> > > available, i.e. it's a problem that ARM compiler doesn't have this
> >> > > optimization, don't punish other architecture of no reason.
>
> What is Arm specific here? I'm not aware of the compiler doing anything
Because Arm is the only 32bit architecture that selects CONFIG_HAVE_RUST
for non-UML cases, i.e. this is the only 32bit architecture that has
this problem. If your point is we should do this for all 32bit
architectures, then I won't disagree. Just s/CONFIG_ARM/CONFIG_32BIT
then.
Regards,
Boqun
> different from the other 32-bit architectures, though most are missing
> an optimized __arch_xprod_64() and fall back to slightly worse code
> from the asm-generic version.
>
> > Copy-paste errors:
> >
> > unsafe { bindings::ktime_to_ms(ns) }
> >
> >> }
> >>
> >> #[cfg(not(CONFIG_ARM))]
> >> fn ns_to_ms(ns: i64) -> i64 {
> >> self.as_nanos() / NSEC_PER_MSEC
> >
> > ns / NSEC_PER_MSEC
>
> I'm sure this is still broken on all 32-bit targets.
>
> Arnd
next prev parent reply other threads:[~2025-05-01 23:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-01 1:58 [PATCH v1] rust: time: Avoid 64-bit integer division FUJITA Tomonori
2025-05-01 2:45 ` FUJITA Tomonori
2025-05-01 9:24 ` Miguel Ojeda
2025-05-01 12:02 ` FUJITA Tomonori
2025-05-01 8:01 ` Christian Schrefl
2025-05-01 9:22 ` Miguel Ojeda
2025-05-01 12:26 ` Boqun Feng
2025-05-01 12:37 ` Boqun Feng
2025-05-01 13:48 ` FUJITA Tomonori
2025-05-01 14:06 ` Boqun Feng
2025-05-01 13:07 ` FUJITA Tomonori
2025-05-01 13:12 ` Boqun Feng
2025-05-01 13:20 ` Boqun Feng
2025-05-01 15:11 ` Arnd Bergmann
2025-05-01 23:03 ` Boqun Feng [this message]
2025-05-01 23:38 ` Christian Schrefl
2025-05-03 0:14 ` FUJITA Tomonori
2025-05-01 13:22 ` Miguel Ojeda
2025-05-01 13:25 ` Boqun Feng
2025-05-01 13:38 ` FUJITA Tomonori
2025-05-05 10:46 ` Andreas Hindborg
2025-05-05 11:10 ` FUJITA Tomonori
2025-05-05 11:51 ` Andreas Hindborg
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=aBP9yvWnB66qJeRh@Mac.home \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=anna-maria@linutronix.de \
--cc=arnd@arndb.de \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=chrisi.schrefl@gmail.com \
--cc=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--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.