<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/rust/kernel/time, 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 HrTimer::expires()</title>
<updated>2025-09-04T14:54:39Z</updated>
<author>
<name>Lyude Paul</name>
<email>lyude@redhat.com</email>
</author>
<published>2025-08-21T19:32:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4b0147494275fdbea98305f4ddad7e2def7b556f'/>
<id>urn:sha1:4b0147494275fdbea98305f4ddad7e2def7b556f</id>
<content type='text'>
Add a simple callback for retrieving the current expiry time for an
HrTimer. In rvkms, we use the HrTimer expiry value in order to calculate
the approximate vblank timestamp during each emulated vblank interrupt.

Signed-off-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Link: https://lore.kernel.org/r/20250821193259.964504-8-lyude@redhat.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: Add forward_now() to HrTimer and HrTimerCallbackContext</title>
<updated>2025-09-04T14:54:39Z</updated>
<author>
<name>Lyude Paul</name>
<email>lyude@redhat.com</email>
</author>
<published>2025-08-21T19:32:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ac0a7bd27f6593dfe9ea6b65538bebbbd8322241'/>
<id>urn:sha1:ac0a7bd27f6593dfe9ea6b65538bebbbd8322241</id>
<content type='text'>
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-6-lyude@redhat.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<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>rust: hrtimer: Add HrTimer::raw_forward() 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:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3efb9ce91c5279d7ea73563d1fb136077f52dd2e'/>
<id>urn:sha1:3efb9ce91c5279d7ea73563d1fb136077f52dd2e</id>
<content type='text'>
Within the hrtimer API there are quite a number of functions that can only
be safely called from one of two contexts:

* When we have exclusive access to the hrtimer and the timer is not active.
* When we're within the hrtimer's callback context as it is being executed.

This commit adds bindings for hrtimer_forward() for the first such context,
along with HrTimer::raw_forward() for later use in implementing the
hrtimer_forward() in the latter context.

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-4-lyude@redhat.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: Add HrTimerInstant</title>
<updated>2025-09-04T14:54:39Z</updated>
<author>
<name>Lyude Paul</name>
<email>lyude@redhat.com</email>
</author>
<published>2025-08-21T19:32:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0e2aab67f2d5716e8db73b6d0719208b44086ed5'/>
<id>urn:sha1:0e2aab67f2d5716e8db73b6d0719208b44086ed5</id>
<content type='text'>
Since we want to add HrTimer methods that can accept Instants, we will want
to make sure that for each method we are using the correct Clocksource for
the given HrTimer. This would get a bit overly-verbose, so add a simple
HrTimerInstant type-alias to handle this for us.

Signed-off-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Link: https://lore.kernel.org/r/20250821193259.964504-3-lyude@redhat.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: hrtimer: Document the return value for HrTimerHandle::cancel()</title>
<updated>2025-09-04T14:54:39Z</updated>
<author>
<name>Lyude Paul</name>
<email>lyude@redhat.com</email>
</author>
<published>2025-08-21T19:32:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a984da24e7ac411c95bab7b6c127bae4927f9d03'/>
<id>urn:sha1:a984da24e7ac411c95bab7b6c127bae4927f9d03</id>
<content type='text'>
Just a drive-by fix I noticed: we don't actually document what the return
value from cancel() does, so do that.

Signed-off-by: Lyude Paul &lt;lyude@redhat.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Link: https://lore.kernel.org/r/20250821193259.964504-2-lyude@redhat.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: time: Pass correct timer mode ID to hrtimer_start_range_ns</title>
<updated>2025-07-16T22:55:35Z</updated>
<author>
<name>Lyude Paul</name>
<email>lyude@redhat.com</email>
</author>
<published>2025-07-10T22:51:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=23b128bba76776541dc09efaf3acf6242917e1f0'/>
<id>urn:sha1:23b128bba76776541dc09efaf3acf6242917e1f0</id>
<content type='text'>
While rebasing rvkms I noticed that timers I was setting seemed to have
pretty random timer values that amounted slightly over 2x the time value I
set each time. After a lot of debugging, I finally managed to figure out
why: it seems that since we moved to Instant and Delta, we mistakenly
began passing the clocksource ID to hrtimer_start_range_ns, when we should
be passing the timer mode instead. Presumably, this works fine for simple
relative timers - but immediately breaks on other types of timers.

So, fix this by passing the ID for the timer mode instead.

Signed-off-by: Lyude Paul &lt;lyude@redhat.com&gt;
Acked-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Reviewed-by: FUJITA Tomonori &lt;fujita.tomonori@gmail.com&gt;
Fixes: e0c0ab04f678 ("rust: time: Make HasHrTimer generic over HrTimerMode")
Link: https://lore.kernel.org/r/20250710225129.670051-1-lyude@redhat.com
[ Removed cast, applied `rustfmt`, fixed `Fixes:` tag. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@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: types: rename Opaque::raw_get to cast_into</title>
<updated>2025-07-15T20:26:11Z</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2025-06-24T15:27:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=64fb810bce03a4e2b4d3ecbba04bb97da3536dd8'/>
<id>urn:sha1:64fb810bce03a4e2b4d3ecbba04bb97da3536dd8</id>
<content type='text'>
In the previous patch we added Opaque::cast_from() that performs the
opposite operation to Opaque::raw_get(). For consistency with this
naming, rename raw_get() to cast_from().

There are a few other options such as calling cast_from() something
closer to raw_get() rather than renaming this method. However, I could
not find a great naming scheme that works with raw_get(). The previous
version of this patch used from_raw(), but functions of that name
typically have a different signature, so that's not a great option.

Suggested-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Acked-by: Benno Lossin &lt;lossin@kernel.org&gt;
Acked-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Acked-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Reviewed-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Acked-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Link: https://lore.kernel.org/r/20250624-opaque-from-raw-v2-2-e4da40bdc59c@google.com
[ Removed `HrTimer::raw_get` change. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: time: Add wrapper for fsleep() function</title>
<updated>2025-06-30T11:22:05Z</updated>
<author>
<name>FUJITA Tomonori</name>
<email>fujita.tomonori@gmail.com</email>
</author>
<published>2025-06-17T14:41:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d4b29ddf82a458935f1bd4909b8a7a13df9d3bdc'/>
<id>urn:sha1:d4b29ddf82a458935f1bd4909b8a7a13df9d3bdc</id>
<content type='text'>
Add a wrapper for fsleep(), flexible sleep functions in
include/linux/delay.h which typically deals with hardware delays.

The kernel supports several sleep functions to handle various lengths
of delay. This adds fsleep(), automatically chooses the best sleep
method based on a duration.

fsleep() can only be used in a nonatomic context. This requirement is
not checked by these abstractions, but it is intended that klint [1]
or a similar tool will be used to check it in the future.

Link: https://rust-for-linux.com/klint [1]
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Signed-off-by: FUJITA Tomonori &lt;fujita.tomonori@gmail.com&gt;
Link: https://lore.kernel.org/r/20250617144155.3903431-3-fujita.tomonori@gmail.com
Signed-off-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
</content>
</entry>
</feed>
