<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/rust/kernel/time/hrtimer, branch v6.18</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.18</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.18'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-09-04T14:54:39Z</updated>
<entry>
<title>rust: hrtimer: Add HrTimerCallbackContext and ::forward()</title>
<updated>2025-09-04T14:54:39Z</updated>
<author>
<name>Lyude Paul</name>
<email>lyude@redhat.com</email>
</author>
<published>2025-08-21T19:32:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3f2a5ba784b808109cac0aac921213e43143a216'/>
<id>urn:sha1:3f2a5ba784b808109cac0aac921213e43143a216</id>
<content type='text'>
With Linux's hrtimer API, there's a number of methods that can only be
called in two situations:

* When we have exclusive access to the hrtimer and it is not currently
  active
* When we're within the context of an hrtimer callback context

This commit handles the second situation and implements hrtimer_forward()
support in the context of a timer callback. We do this by introducing a
HrTimerCallbackContext type which is provided to users during the
RawHrTimerCallback::run() callback, and then add a forward() function to
the type.

Signed-off-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Link: https://lore.kernel.org/r/20250821193259.964504-5-lyude@redhat.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'rust-timekeeping-for-v6.17' of https://github.com/Rust-for-Linux/linux into rust-next</title>
<updated>2025-07-16T21:45:08Z</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2025-07-16T21:45:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=77580e801a981f0c24c886460840d1ed70c794ae'/>
<id>urn:sha1:77580e801a981f0c24c886460840d1ed70c794ae</id>
<content type='text'>
Pull timekeeping updates from Andreas Hindborg:

 - Make 'Instant' generic over clock source. This allows the compiler to
   assert that arithmetic expressions involving the 'Instant' use
   'Instants' based on the same clock source.

 - Make 'HrTimer' generic over the timer mode. 'HrTimer' timers take a
   'Duration' or an 'Instant' when setting the expiry time, depending on
   the timer mode. With this change, the compiler can check the type
   matches the timer mode.

 - Add an abstraction for 'fsleep'. 'fsleep' is a flexible sleep
   function that will select an appropriate sleep method depending on
   the requested sleep time.

 - Avoid 64-bit divisions on 32-bit hardware when calculating
   timestamps.

 - Seal the 'HrTimerMode' trait. This prevents users of the
   'HrTimerMode' from implementing the trait on their own types.

* tag 'rust-timekeeping-for-v6.17' of https://github.com/Rust-for-Linux/linux:
  rust: time: Add wrapper for fsleep() function
  rust: time: Seal the HrTimerMode trait
  rust: time: Remove Ktime in hrtimer
  rust: time: Make HasHrTimer generic over HrTimerMode
  rust: time: Add HrTimerExpires trait
  rust: time: Replace HrTimerMode enum with trait-based mode types
  rust: time: Add ktime_get() to ClockSource trait
  rust: time: Make Instant generic over ClockSource
  rust: time: Replace ClockId enum with ClockSource trait
  rust: time: Avoid 64-bit integer division on 32-bit architectures
</content>
</entry>
<entry>
<title>rust: time: Make HasHrTimer generic over HrTimerMode</title>
<updated>2025-06-24T17:52:47Z</updated>
<author>
<name>FUJITA Tomonori</name>
<email>fujita.tomonori@gmail.com</email>
</author>
<published>2025-06-10T13:28:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e0c0ab04f6785abaa71b9b8dc252cb1a2072c225'/>
<id>urn:sha1:e0c0ab04f6785abaa71b9b8dc252cb1a2072c225</id>
<content type='text'>
Add a `TimerMode` associated type to the `HasHrTimer` trait to
represent the operational mode of the timer, such as absolute or
relative expiration. This new type must implement the `HrTimerMode`
trait, which defines how expiration values are interpreted.

Update the `start()` method to accept an `expires` parameter of type
`&lt;Self::TimerMode as HrTimerMode&gt;::Expires` instead of the fixed `Ktime`.
This enables different timer modes to provide strongly typed expiration
values, such as `Instant&lt;C&gt;` or `Delta`.

The `impl_has_hr_timer` macro is also extended to allow specifying the
`HrTimerMode`. In the following example, it guarantees that the
`start()` method for `Foo` only accepts `Instant&lt;Monotonic&gt;`. Using a
`Delta` or an `Instant` with a different clock source will result in a
compile-time error:

struct Foo {
    #[pin]
    timer: HrTimer&lt;Self&gt;,
}

impl_has_hr_timer! {
    impl HasHrTimer&lt;Self&gt; for Foo {
        mode : AbsoluteMode&lt;Monotonic&gt;,
        field : self.timer
    }
}

This design eliminates runtime mismatches between expires types and
clock sources, and enables stronger type-level guarantees throughout
hrtimer.

Signed-off-by: FUJITA Tomonori &lt;fujita.tomonori@gmail.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Link: https://lore.kernel.org/r/20250610132823.3457263-5-fujita.tomonori@gmail.com
[ changed conversion method names to `as_*` - Andreas ]
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: enable `clippy::ptr_as_ptr` lint</title>
<updated>2025-06-22T21:08:42Z</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@gmail.com</email>
</author>
<published>2025-06-15T20:55:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fcad9bbf9e1a7de6c53908954ba1b1a1ab11ef1e'/>
<id>urn:sha1:fcad9bbf9e1a7de6c53908954ba1b1a1ab11ef1e</id>
<content type='text'>
In Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]:

&gt; Though `as` casts between raw pointers are not terrible,
&gt; `pointer::cast` is safer because it cannot accidentally change the
&gt; pointer's mutability, nor cast the pointer to other types like `usize`.

There are a few classes of changes required:
- Modules generated by bindgen are marked
  `#[allow(clippy::ptr_as_ptr)]`.
- Inferred casts (` as _`) are replaced with `.cast()`.
- Ascribed casts (` as *... T`) are replaced with `.cast::&lt;T&gt;()`.
- Multistep casts from references (` as *const _ as *const T`) are
  replaced with `core::ptr::from_ref(&amp;x).cast()` with or without `::&lt;T&gt;`
  according to the previous rules. The `core::ptr::from_ref` call is
  required because `(x as *const _).cast::&lt;T&gt;()` results in inference
  failure.
- Native literal C strings are replaced with `c_str!().as_char_ptr()`.
- `*mut *mut T as _` is replaced with `let *mut *const T = (*mut *mut
  T)`.cast();` since pointer to pointer can be confusing.

Apply these changes and enable the lint -- no functional change
intended.

Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr [1]
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Reviewed-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Tamir Duberstein &lt;tamird@gmail.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-1-f43b024581e8@gmail.com
[ Added `.cast()` for `opp`. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: Add Ktime temporarily</title>
<updated>2025-04-29T13:31:07Z</updated>
<author>
<name>FUJITA Tomonori</name>
<email>fujita.tomonori@gmail.com</email>
</author>
<published>2025-04-23T19:28:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1116f0c5ff3385658ceb8ae2c5c4cb05bd7836d7'/>
<id>urn:sha1:1116f0c5ff3385658ceb8ae2c5c4cb05bd7836d7</id>
<content type='text'>
Add Ktime temporarily until hrtimer is refactored to use Instant and
Delta types.

Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Reviewed-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: FUJITA Tomonori &lt;fujita.tomonori@gmail.com&gt;
Link: https://lore.kernel.org/r/20250423192857.199712-2-fujita.tomonori@gmail.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: implement `HrTimerPointer` for `Pin&lt;Box&lt;T&gt;&gt;`</title>
<updated>2025-03-22T11:08:54Z</updated>
<author>
<name>Andreas Hindborg</name>
<email>a.hindborg@kernel.org</email>
</author>
<published>2025-03-09T15:19:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=374b60a0134e4b136f6c3d8b3c9eb99b3b104249'/>
<id>urn:sha1:374b60a0134e4b136f6c3d8b3c9eb99b3b104249</id>
<content type='text'>
Allow `Pin&lt;Box&lt;T&gt;&gt;` to be the target of a timer callback.

Acked-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Acked-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Link: https://lore.kernel.org/r/20250309-hrtimer-v3-v6-12-rc2-v12-10-73586e2bd5f1@kernel.org
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin&lt;&amp;mut T&gt;`</title>
<updated>2025-03-22T11:08:54Z</updated>
<author>
<name>Andreas Hindborg</name>
<email>a.hindborg@kernel.org</email>
</author>
<published>2025-03-09T15:18:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=042b0c7947d39aeac34b35fb89034ca1345f1fc3'/>
<id>urn:sha1:042b0c7947d39aeac34b35fb89034ca1345f1fc3</id>
<content type='text'>
Allow pinned mutable references to structs that contain a `HrTimer` node to
be scheduled with the `hrtimer` subsystem.

Acked-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Acked-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Link: https://lore.kernel.org/r/20250309-hrtimer-v3-v6-12-rc2-v12-8-73586e2bd5f1@kernel.org
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin&lt;&amp;T&gt;`</title>
<updated>2025-03-22T11:08:54Z</updated>
<author>
<name>Andreas Hindborg</name>
<email>a.hindborg@kernel.org</email>
</author>
<published>2025-03-09T15:18:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=582523d9de9a8875df62a08af7443884ff5d9969'/>
<id>urn:sha1:582523d9de9a8875df62a08af7443884ff5d9969</id>
<content type='text'>
Allow pinned references to structs that contain a `HrTimer` node to be
scheduled with the `hrtimer` subsystem.

Acked-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Acked-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Link: https://lore.kernel.org/r/20250309-hrtimer-v3-v6-12-rc2-v12-7-73586e2bd5f1@kernel.org
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: allow timer restart from timer handler</title>
<updated>2025-03-22T11:08:54Z</updated>
<author>
<name>Andreas Hindborg</name>
<email>a.hindborg@kernel.org</email>
</author>
<published>2025-03-09T15:18:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=94e05a66ea3ebed48e7e1a0dee68d40184386d25'/>
<id>urn:sha1:94e05a66ea3ebed48e7e1a0dee68d40184386d25</id>
<content type='text'>
Allow timer handlers to report that they want a timer to be restarted after
the timer handler has finished executing.

Acked-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Acked-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Reviewed-by: Tamir Duberstein &lt;tamird@gmail.com&gt;
Reviewed-by: Lyude Paul &lt;lyude@redhat.com&gt;
Link: https://lore.kernel.org/r/20250309-hrtimer-v3-v6-12-rc2-v12-4-73586e2bd5f1@kernel.org
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: implement `HrTimerPointer` for `Arc`</title>
<updated>2025-03-11T20:00:42Z</updated>
<author>
<name>Andreas Hindborg</name>
<email>a.hindborg@kernel.org</email>
</author>
<published>2025-03-09T15:18:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d7bf4786b5250b0e490a937d1f8a16ee3a54adbe'/>
<id>urn:sha1:d7bf4786b5250b0e490a937d1f8a16ee3a54adbe</id>
<content type='text'>
Allow the use of intrusive `hrtimer` fields in structs that are managed by
an `Arc` by implementing `HrTimerPointer` and `RawTimerCallbck` for `Arc`.

Acked-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Acked-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Link: https://lore.kernel.org/r/20250309-hrtimer-v3-v6-12-rc2-v12-3-73586e2bd5f1@kernel.org
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
</feed>
