linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/7] rust/hrtimer: Various hrtimer + time additions
@ 2025-08-13 22:42 Lyude Paul
  2025-08-13 22:42 ` [PATCH v7 1/7] rust: hrtimer: Document the return value for HrTimerHandle::cancel() Lyude Paul
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Lyude Paul @ 2025-08-13 22:42 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel, Thomas Gleixner, Andreas Hindborg,
	FUJITA Tomonori
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich

This is a collection of various bindings that I added to hrtimer when I
was originally getting it ready to be used in rvkms. I've mostly been
waiting for Andreas's hrtimer series to go upstream before submitting
these.

All of these are currently being used within rvkms for vblank emulation.

Previous versions:
  Version 1: https://lkml.org/lkml/2025/4/2/1474
  Version 2: https://lkml.org/lkml/2025/4/15/1750
  Version 3 (only a revision of one patch): https://lkml.org/lkml/2025/4/15/1780
  Version 4: https://lkml.org/lkml/2025/4/29/1715
  Version 5: https://lkml.org/lkml/2025/6/13/1785
  Version 6: https://lkml.org/lkml/2025/7/24/1390

Usage example:
 (keep in mind, I haven't rebased the example entirely - but the only
  differences there is a few comments)

  https://gitlab.freedesktop.org/lyudess/linux/-/tree/rvkms-slim/rust/kernel?ref_type=heads

Changelog down below

Lyude Paul (7):
  rust: hrtimer: Document the return value for HrTimerHandle::cancel()
  rust: hrtimer: Add HrTimerInstant
  rust: hrtimer: Add HrTimer::raw_forward() and forward()
  rust: hrtimer: Add HrTimerCallbackContext and ::forward()
  rust: hrtimer: Add forward_now() to HrTimer and HrTimerCallbackContext
  rust: time: Add Instant::from_nanos()
  rust: hrtimer: Add HrTimer::expires()

 rust/kernel/time.rs                 |  22 ++++
 rust/kernel/time/hrtimer.rs         | 152 +++++++++++++++++++++++++++-
 rust/kernel/time/hrtimer/arc.rs     |   9 +-
 rust/kernel/time/hrtimer/pin.rs     |   9 +-
 rust/kernel/time/hrtimer/pin_mut.rs |  12 ++-
 rust/kernel/time/hrtimer/tbox.rs    |   9 +-
 6 files changed, 204 insertions(+), 9 deletions(-)

Changelog:
  rust: hrtimer: Document the return value for HrTimerHandle::cancel()
    V4:
      * Reword to "Returns `true` if the timer was running."
  rust: hrtimer: Add HrTimerInstant
    V4:
      * Fix the safety contract for raw_forward()
      * Require Pin<&mut Self>, not &mut self
      * Drop incorrect UniquePin example
      * Rewrite documentation a bit (re: Andreas)
    V6:
      * Remove the reference to HrTimerCallbackContext::forward() until this
        function gets added.
    V7:
      * Split up Timer::forward() a bit, apply Andreas's SAFETY comment
        recommendations
  rust: hrtimer: Add HrTimer::raw_forward() and forward()
  rust: hrtimer: Add HrTimerCallbackContext and ::forward()
    V2:
      * Improve SAFETY comments for HrTimerCallbackContext uses (I forgot to
        mention that we're within RawHrTimerCallback::run()
      * Split forward into forward() and raw_forward() since we're going to have
        two contexts that we can call forward() from now.
      * Clarify contexts in which certain hrtimer methods can be called.
      * Make sure that we use a mutable reference for forward() here - just in
        case :).
      * Rename interval to duration
    V3:
      * Rename duration -back- to interval (now that I actually have read
        hrtimer_forward's source, interval does make more sense than duration
        considering the fact we return the number of overruns that occurred
        according to the given interval).
      * Rewrite documentation a bit (re: Andreas)
    V5:
      * Fix unbounded T on HrTimerCallbackContext
    V6:
      * Move reference to HrTimerCallbackContext::forward() in HrTimer::forward()
        comments into this commit so rustdoc doesn't fail.
      * Deduplicate documentation for HrTimerCallbackContext::forward()
      * Add missing changelog note

  rust: hrtimer: Add forward_now() to HrTimer and HrTimerCallbackContext
    V2:
      * Change from Ktime to Delta
      * Make sure that forward_now() takes a mutable reference to the timer
        struct
      * Reword this to point out that we're adding forward_now() to both callback
        context and mutable timer reference
      * Rename interval to duration
    V4:
      * Fix rust documentation for HrTimerCallbackContext (forgot to update both
        forward_now() declarations)
      * Use Pin<&mut Self> for context-less forward.
    V6:
      * Drop raw_cb_time(), use Instant::now() instead
      * Split out expires() from this patch, at some point it seems I mistakenly
        combined it with this patch
    V7:
      * Remove leftover comment about raw_cb_time from patch description

  rust: time: Add Instant::from_nanos()
    V4:
      * Turn from_nanos() into an unsafe function in order to ensure that we
        uphold the invariants of Instant
    V5:
      * Add debug_assert!() to from_nanos

  rust: hrtimer: Add HrTimer::expires()


base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
-- 
2.50.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-08-18 18:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 22:42 [PATCH v7 0/7] rust/hrtimer: Various hrtimer + time additions Lyude Paul
2025-08-13 22:42 ` [PATCH v7 1/7] rust: hrtimer: Document the return value for HrTimerHandle::cancel() Lyude Paul
2025-08-13 22:42 ` [PATCH v7 2/7] rust: hrtimer: Add HrTimerInstant Lyude Paul
2025-08-13 22:42 ` [PATCH v7 3/7] rust: hrtimer: Add HrTimer::raw_forward() and forward() Lyude Paul
2025-08-15  8:17   ` Andreas Hindborg
2025-08-13 22:42 ` [PATCH v7 4/7] rust: hrtimer: Add HrTimerCallbackContext and ::forward() Lyude Paul
2025-08-13 22:42 ` [PATCH v7 5/7] rust: hrtimer: Add forward_now() to HrTimer and HrTimerCallbackContext Lyude Paul
2025-08-13 22:42 ` [PATCH v7 6/7] rust: time: Add Instant::from_nanos() Lyude Paul
2025-08-15  8:11   ` Andreas Hindborg
2025-08-17  7:18   ` FUJITA Tomonori
2025-08-18 18:52     ` Lyude Paul
2025-08-13 22:42 ` [PATCH v7 7/7] rust: hrtimer: Add HrTimer::expires() Lyude Paul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).