From: Boqun Feng <boqun.feng@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
rust-for-linux@vger.kernel.org, "Gary Guo" <gary@garyguo.net>,
"Alice Ryhl" <aliceryhl@google.com>,
me@kloenk.dev, daniel.almeida@collabora.com,
linux-kernel@vger.kernel.org, Netdev <netdev@vger.kernel.org>,
"Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Anna-Maria Gleixner" <anna-maria@linutronix.de>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"John Stultz" <jstultz@google.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Benjamin Segall" <bsegall@google.com>,
"Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
tgunders@redhat.com, david.laight.linux@gmail.com,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Jocelyn Falempe" <jfalempe@redhat.com>,
"Russell King" <linux@armlinux.org.uk>,
"Christian Schrefl" <chrisi.schrefl@gmail.com>,
"Linus Walleij" <linus.walleij@linaro.org>
Subject: Re: [PATCH v15 5/6] rust: time: Add wrapper for fsleep() function
Date: Tue, 29 Apr 2025 12:14:04 -0700 [thread overview]
Message-ID: <681124ff.050a0220.13a0e7.2c80@mx.google.com> (raw)
In-Reply-To: <2d89292f-b02c-47b1-9299-92c5f4ba4c9d@app.fastmail.com>
On Tue, Apr 29, 2025 at 08:33:47PM +0200, Arnd Bergmann wrote:
> On Tue, Apr 29, 2025, at 19:15, Boqun Feng wrote:
> > On Tue, Apr 29, 2025 at 06:11:02PM +0200, Arnd Bergmann wrote:
> >> On Tue, Apr 29, 2025, at 18:03, Boqun Feng wrote:
> >
> > Would it make sense if we rely on compiler optimization when it's
> > avaiable (for x86_64, arm64, riscv, etc), and only call ktime_to_ms() if
> > not? The downside of calling ktime_to_ms() are:
> >
> > * it's a call function, and cannot be inlined with LTO or INLINE_HELPER:
> >
> > https://lore.kernel.org/all/20250319205141.3528424-1-gary@garyguo.net/
> >
> > * it doesn't provide the overflow checking even if
> > CONFIG_RUST_OVERFLOW_CHECKS=y
> >
> > Thoughts?
>
> The function call overhead is tiny compared to replacing a 64-bit
> division with a constant mult/shift.
>
Just to be clear, are you essientially saying that even in C,
ktime_to_ms() is not worth inlining? Because the call overhead is tiny
compared to the function own cost?
My impression is that on x86 at least, function call is 10+ cycles, and
multiply is 3 cycles, so I would think that ktime_to_ms() itself is at
most 10 cycles. Maybe I'm out of date of the modern micro-architecture?
> What is the possible overflow that can happen here? For a constant
> division at least there is no chance of divide-by-zero. Do you mean
> truncating to 32 bit?
>
I was referring the last part of Miguel's email:
https://lore.kernel.org/rust-for-linux/CANiq72mMRpY4NC4_8v_wDpq6Z3qs99Y8gXd-7XL_3Bed58gkJg@mail.gmail.com/
Regards,
Boqun
> Arnd
next prev parent reply other threads:[~2025-04-29 19:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 19:28 [PATCH v15 0/6] rust: Add IO polling FUJITA Tomonori
2025-04-23 19:28 ` [PATCH v15 1/6] rust: hrtimer: Add Ktime temporarily FUJITA Tomonori
2025-04-23 19:28 ` [PATCH v15 2/6] rust: time: Add PartialEq/Eq/PartialOrd/Ord trait to Ktime FUJITA Tomonori
2025-04-23 19:28 ` [PATCH v15 3/6] rust: time: Introduce Delta type FUJITA Tomonori
2025-04-23 19:28 ` [PATCH v15 4/6] rust: time: Introduce Instant type FUJITA Tomonori
2025-04-23 19:28 ` [PATCH v15 5/6] rust: time: Add wrapper for fsleep() function FUJITA Tomonori
2025-04-28 18:16 ` Andreas Hindborg
2025-04-29 13:17 ` FUJITA Tomonori
2025-04-29 14:16 ` Christian Schrefl
2025-04-29 14:31 ` Russell King (Oracle)
2025-04-29 14:35 ` Miguel Ojeda
2025-04-30 13:51 ` FUJITA Tomonori
2025-04-30 14:50 ` Boqun Feng
2025-04-30 16:43 ` Christian Schrefl
2025-04-29 15:51 ` Arnd Bergmann
2025-04-29 16:03 ` Boqun Feng
2025-04-29 16:11 ` Arnd Bergmann
2025-04-29 17:15 ` Boqun Feng
2025-04-29 18:33 ` Arnd Bergmann
2025-04-29 19:14 ` Boqun Feng [this message]
2025-04-29 19:27 ` Boqun Feng
2025-04-23 19:28 ` [PATCH v15 6/6] MAINTAINERS: rust: Add a new section for all of the time stuff FUJITA Tomonori
2025-04-30 10:40 ` [PATCH v15 0/6] rust: Add IO polling 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=681124ff.050a0220.13a0e7.2c80@mx.google.com \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andrew@lunn.ch \
--cc=anna-maria@linutronix.de \
--cc=arnd@arndb.de \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=bsegall@google.com \
--cc=chrisi.schrefl@gmail.com \
--cc=daniel.almeida@collabora.com \
--cc=david.laight.linux@gmail.com \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=hkallweit1@gmail.com \
--cc=jfalempe@redhat.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=me@kloenk.dev \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=tgunders@redhat.com \
--cc=tmgross@umich.edu \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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.