rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/14] hrtimer Rust API
@ 2024-09-17 22:27 Andreas Hindborg
  2024-09-17 22:27 ` [PATCH v2 01/14] rust: time: Add Ktime::from_ns() Andreas Hindborg
                   ` (15 more replies)
  0 siblings, 16 replies; 59+ messages in thread
From: Andreas Hindborg @ 2024-09-17 22:27 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Anna-Maria Behnsen,
	Frederic Weisbecker, Thomas Gleixner
  Cc: Andreas Hindborg, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Alice Ryhl, rust-for-linux, linux-kernel

Hi!

This series adds support for using the `hrtimer` subsystem from Rust code.

I tried breaking up the code in some smaller patches, hopefully that will
ease the review process a bit.

The major change in this series is the use of a handle to carry ownership
of the callback target. In v1, we used the armed timer to carry ownership
of the callback target. This caused issues when the live timer became the
last owner of the callback target, because the target would be dropped in
timer callback context. That is solved by using a handle instead.

A request from Thomas on v1 was to add a more complete API. While I did add
more features, we are still missing some. In the interest of getting the
patches on list prior to LPC 2024, I am leaving out the following planned
features:

 - hrtimer_sleeper, schedule_hrtimeout, hrtimer_nanosleep  and friends
 - introspection functions:
   - try_cancel
   - get_remaining
   - active
   - queued
   - callback_running
 - hrtimer_forward
 - access to timer callback target through timer handle

I plan to add these features in the comming months. Adding the above
features should not cause much churn, and pending positive review, I see no
reason to not pick up this series first.

To make it absolutely clear that I am willing to maintain the code I
submit, I added a mantainer entry in the last patch. Feel free to drop it,
if you want to make other arrangements.

---

Changes from v1:
 - use a handle to own the timer callback target
 - add ability to for callback to reschedule timer
 - improve `impl_has_timer` to allow generics
 - add support for stack allocated timers
 - add support for scheduling closures
 - use `Ktime` for setting expiration
 - use `CondVar` instead of `AtomicBool` in examples
 - rebase on 6.11
 - improve documentation

This series is a dependency for unmerged features of the Rust null block driver
[1], and for rkvms [2].

Link: https://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/linux.git/log/?h=rnull-v6.11-rc2 [1]
Link: https://gitlab.freedesktop.org/lyudess/linux/-/tree/rvkms-wip [2]

---

Andreas Hindborg (13):
  rust: hrtimer: introduce hrtimer support
  rust: sync: add `Arc::as_ptr`
  rust: sync: add `Arc::clone_from_raw`
  rust: hrtimer: implement `TimerPointer` for `Arc`
  rust: hrtimer: allow timer restart from timer handler
  rust: hrtimer: add `UnsafeTimerPointer`
  rust: hrtimer: implement `UnsafeTimerPointer` for `Pin<&T>`
  rust: hrtimer: implement `UnsafeTimerPointer` for `Pin<&mut T>`
  rust: hrtimer: add `hrtimer::ScopedTimerPointer`
  rust: hrtimer: allow specifying a distinct callback parameter
  rust: hrtimer: implement `TimerPointer` for `Pin<Box<T>>`
  rust: hrtimer: add `schedule_function` to schedule closures
  rust: hrtimer: add maintainer entry

Lyude Paul (1):
  rust: time: Add Ktime::from_ns()

 MAINTAINERS                    |  10 +
 rust/kernel/hrtimer.rs         | 550 +++++++++++++++++++++++++++++++++
 rust/kernel/hrtimer/arc.rs     |  86 ++++++
 rust/kernel/hrtimer/closure.rs |  72 +++++
 rust/kernel/hrtimer/pin.rs     |  97 ++++++
 rust/kernel/hrtimer/pin_mut.rs |  99 ++++++
 rust/kernel/hrtimer/tbox.rs    |  95 ++++++
 rust/kernel/lib.rs             |   1 +
 rust/kernel/sync/arc.rs        |  28 ++
 rust/kernel/time.rs            |   8 +
 10 files changed, 1046 insertions(+)
 create mode 100644 rust/kernel/hrtimer.rs
 create mode 100644 rust/kernel/hrtimer/arc.rs
 create mode 100644 rust/kernel/hrtimer/closure.rs
 create mode 100644 rust/kernel/hrtimer/pin.rs
 create mode 100644 rust/kernel/hrtimer/pin_mut.rs
 create mode 100644 rust/kernel/hrtimer/tbox.rs


base-commit: 98f7e32f20d28ec452afb208f9cffc08448a2652
-- 
2.46.0



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

end of thread, other threads:[~2024-10-14 11:59 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 22:27 [PATCH v2 00/14] hrtimer Rust API Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 01/14] rust: time: Add Ktime::from_ns() Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 02/14] rust: hrtimer: introduce hrtimer support Andreas Hindborg
2024-09-18 18:13   ` Benno Lossin
2024-09-19  5:43     ` Andreas Hindborg
2024-09-19 14:09       ` Benno Lossin
2024-09-23 16:35         ` Andreas Hindborg
2024-09-23 16:59           ` Benno Lossin
2024-10-10 12:24             ` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 03/14] rust: sync: add `Arc::as_ptr` Andreas Hindborg
2024-09-19 14:03   ` Benno Lossin
2024-09-21 15:58     ` Gary Guo
2024-09-21 18:17       ` Benno Lossin
2024-09-23  8:14       ` Alice Ryhl
2024-10-01  4:56     ` Dirk Behme
2024-10-01  8:39       ` Benno Lossin
2024-09-17 22:27 ` [PATCH v2 04/14] rust: sync: add `Arc::clone_from_raw` Andreas Hindborg
2024-09-18 18:19   ` Benno Lossin
2024-09-18 20:12     ` Gary Guo
2024-09-18 21:09       ` Benno Lossin
2024-09-19  6:00       ` Andreas Hindborg
2024-09-19 14:15         ` Benno Lossin
2024-09-20  8:25           ` Andreas Hindborg
2024-09-19  5:54     ` Andreas Hindborg
2024-09-19  6:19       ` Andreas Hindborg
2024-09-19  6:41         ` Alice Ryhl
2024-09-17 22:27 ` [PATCH v2 05/14] rust: hrtimer: implement `TimerPointer` for `Arc` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 06/14] rust: hrtimer: allow timer restart from timer handler Andreas Hindborg
2024-09-20 14:25   ` kernel test robot
2024-09-17 22:27 ` [PATCH v2 07/14] rust: hrtimer: add `UnsafeTimerPointer` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 08/14] rust: hrtimer: implement `UnsafeTimerPointer` for `Pin<&T>` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 09/14] rust: hrtimer: implement `UnsafeTimerPointer` for `Pin<&mut T>` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 10/14] rust: hrtimer: add `hrtimer::ScopedTimerPointer` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 11/14] rust: hrtimer: allow specifying a distinct callback parameter Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 12/14] rust: hrtimer: implement `TimerPointer` for `Pin<Box<T>>` Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 13/14] rust: hrtimer: add `schedule_function` to schedule closures Andreas Hindborg
2024-09-17 22:27 ` [PATCH v2 14/14] rust: hrtimer: add maintainer entry Andreas Hindborg
2024-10-12 15:19   ` Boqun Feng
2024-09-30  9:36 ` [PATCH v2 00/14] hrtimer Rust API Anna-Maria Behnsen
2024-10-04 10:47   ` Andreas Hindborg
2024-10-01 12:37 ` Dirk Behme
2024-10-01 14:42   ` Boqun Feng
2024-10-03  8:14     ` Dirk Behme
2024-10-03 13:03       ` Boqun Feng
2024-10-03 16:18         ` Dirk Behme
2024-10-11 14:52     ` Andreas Hindborg
2024-10-11 15:43       ` Dirk Behme
2024-10-11 23:21         ` Boqun Feng
2024-10-12  5:19           ` Dirk Behme
2024-10-12  7:41             ` Boqun Feng
2024-10-12  7:50               ` Dirk Behme
2024-10-12 22:26                 ` Boqun Feng
2024-10-13 17:39                   ` Dirk Behme
2024-10-13 21:06                     ` Boqun Feng
2024-10-14  6:58                       ` Dirk Behme
2024-10-14  9:17                         ` Andreas Hindborg
2024-10-14  9:38                         ` Alice Ryhl
2024-10-14 11:53                           ` Dirk Behme
2024-10-14 11:58                             ` Alice Ryhl

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).