Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH v4 0/2] rust: time: keep Instant invariant when adding/subtracting Delta
@ 2026-12-04  8:34 Franklin-Qi
  2026-12-04  9:28 ` [PATCH v4 1/2] " Franklin-Qi
  2026-12-04  9:29 ` [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping Franklin-Qi
  0 siblings, 2 replies; 3+ messages in thread
From: Franklin-Qi @ 2026-12-04  8:34 UTC (permalink / raw)
  To: Andreas Hindborg, Lyude Paul, Miguel Ojeda, Alice Ryhl
  Cc: FUJITA Tomonori, Boqun Feng, Danilo Krummrich, rust-for-linux,
	Thomas Gleixner, John Stultz, Stephen Boyd, Frederic Weisbecker,
	Anna-Maria Behnsen, Georgios Androutsopoulos, stable, Franklin-Qi

Hi Andreas, Miguel,

This is v4 of the Instant + Delta invariant series.

v3: https://lore.kernel.org/rust-for-linux/20261203092101.63850-1-yusq77@gmail.com/
v2: https://lore.kernel.org/rust-for-linux/20261202080227.898512-1-yusq77@gmail.com/

Changes in v4:
- Address Miguel's review of v3 2/2: restore Instant::from_ktime() with
  debug_assert!(ktime >= 0), and build the KUnit Instant fixtures through
  that constructor instead of writing the private fields directly.
- Add static_assert!(bindings::ktime_t::MAX == i64::MAX) in from_ktime().
  bindings::KTIME_MAX is not exported by bindgen today; ktime_t is s64 and
  KTIME_MAX is documented as i64::MAX, so this is the same upper-bound
  guarantee Miguel asked for.
- from_ktime() is only used by the time KUnit tests at the moment, so it
  carries expect(dead_code) when CONFIG_RUST_TIME_KUNIT_TEST is off (it was
  previously removed after HrTimer::expires() went away).

1/2 is unchanged from v3. 2/2 picks up the constructor change above.

Tested:
- CONFIG_RUST_OVERFLOW_CHECKS=n, CONFIG_RUST_TIME_KUNIT_TEST=y:
  rust_kernel_time: pass:12 fail:0 (includes the Instant clamp cases; one
  expected "clamping" warning on the above-KTIME_MAX path).

Franklin-Qi

Franklin-Qi (2):
  rust: time: keep Instant invariant when adding/subtracting Delta
  rust: time: add KUnit tests for Instant Delta clamping

 rust/kernel/time.rs | 176 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 156 insertions(+), 20 deletions(-)

-- 
2.55.0


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

end of thread, other threads:[~2026-12-04  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  8:34 [PATCH v4 0/2] rust: time: keep Instant invariant when adding/subtracting Delta Franklin-Qi
2026-12-04  9:28 ` [PATCH v4 1/2] " Franklin-Qi
2026-12-04  9:29 ` [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping Franklin-Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox