rust: time: keep Instant invariant when adding/subtracting Delta
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 1 replyIn review
- v21 patch 2 repliesSuperseded
- v11 patch 7 repliesSuperseded
Changes in v3 from the cover letter
- Rebased onto timekeeping-next (Instant is now Instant<C, Nsec>).
- Without overflow checks, also warn once when saturating to KTIME_MAX, not only when clamping a negative result (Tomonori).
- Add a second patch with KUnit tests for Instant +/- Delta clamping (Andreas, Miguel).
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | rust: time: keep Instant invariant when adding/subtracting Deltarust/ | +81 | 0 replies | |
| 2/2 | rust: time: add KUnit tests for Instant Delta clampingrust/ | +52 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/2] rust: time: keep Instant invariant when adding/subtracting Delta
Instant documents that its inner value stays in 0..=KTIME_MAX, but Add/Sub<Delta> only enforced the lower bound under CONFIG_RUST_OVERFLOW_CHECKS. With checks disabled the result could leave that range, which later Instant-Instant subtraction assumes still holds.
This series keeps the existing panic behaviour with overflow checks enabled, and otherwise saturates/clamps into range with a one-shot warning. A follow-up patch adds KUnit coverage for the clamping paths.
Changes in v3:
- Rebased onto timekeeping-next (Instant is now Instant<C, Nsec>).
- Without overflow checks, also warn once when saturating to KTIME_MAX, not only when clamping a negative result (Tomonori).
- Add a second patch with KUnit tests for Instant +/- Delta clamping (Andreas, Miguel).
v2: https://lore.kernel.org/rust-for-linux/[email protected]/
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 | 153 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 133 insertions(+), 20 deletions(-)
base-commit: 8ecc26b396a2b587088e8ffd4d4b77d878f1eb33
Signature · 1 line
2.55.0