Rust for Linux List
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>
Cc: 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,
	"Boqun Feng" <boqun.feng@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 17:51:05 +0200	[thread overview]
Message-ID: <5c18acfc-7893-4731-9292-dc69a7acdff2@app.fastmail.com> (raw)
In-Reply-To: <20250429.221733.2034231929519765445.fujita.tomonori@gmail.com>

On Tue, Apr 29, 2025, at 15:17, FUJITA Tomonori wrote:
> On Mon, 28 Apr 2025 20:16:47 +0200 Andreas Hindborg <a.hindborg@kernel.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.

div64_s64() itself is never optimized for constant arguments since
the C version is not inline, if any driver needs those, this is
better done open-coded so hopefully it gets caught in review
when this is called in a fast path.

       Arnd

  parent reply	other threads:[~2025-04-29 15:51 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 [this message]
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
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=5c18acfc-7893-4731-9292-dc69a7acdff2@app.fastmail.com \
    --to=arnd@arndb.de \
    --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=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox