* [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; 6+ 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] 6+ messages in thread
* [PATCH v4 1/2] rust: time: keep Instant invariant when adding/subtracting Delta
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 ` Franklin-Qi
2026-12-04 10:07 ` FUJITA Tomonori
2026-12-04 9:29 ` [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping Franklin-Qi
1 sibling, 1 reply; 6+ messages in thread
From: Franklin-Qi @ 2026-12-04 9:28 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
Instant documents inner in 0..=KTIME_MAX, but Add/Sub<Delta> only
asserted non-negativity under CONFIG_RUST_OVERFLOW_CHECKS. With checks
disabled, a negative result can be returned, and an addition past
KTIME_MAX silently wraps. A later Instant-Instant subtraction relies on
the invariant and may no longer be overflow-safe.
Keep the existing behaviour under CONFIG_RUST_OVERFLOW_CHECKS and panic
if the result is out of range. Without overflow checks, use saturating
arithmetic and clamp into 0..=KTIME_MAX, printing a warning once for both
a negative result and a saturation at KTIME_MAX, so the invariant is
preserved without crashing the kernel.
Document the panic and clamping conditions in the operators' rustdoc.
Fixes: 22b65a40574e ("rust: time: Implement Add<Delta>/Sub<Delta> for Instant")
Cc: stable@vger.kernel.org
Reported-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1272
Signed-off-by: Franklin-Qi <yusq77@gmail.com>
---
rust/kernel/time.rs | 101 +++++++++++++++++++++++++++++++++++---------
1 file changed, 81 insertions(+), 20 deletions(-)
diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
index 0782fdb06bfc..4ff65c74b5b5 100644
--- a/rust/kernel/time.rs
+++ b/rust/kernel/time.rs
@@ -256,6 +256,51 @@ pub fn elapsed(&self) -> Delta {
pub(crate) fn as_nanos(&self) -> i64 {
self.inner
}
+
+ /// Create an [`Instant`] from the result of an arithmetic operation.
+ ///
+ /// With overflow checks disabled, `sat` is the saturating result and `wrap` is the wrapping
+ /// result of the same operation. A mismatch means the `i64` range was exceeded; a negative
+ /// `sat` means the result fell below 0. Both cases print a warning once and clamp into
+ /// `0..=KTIME_MAX` (`KTIME_MAX` equals `i64::MAX`).
+ ///
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_OVERFLOW_CHECKS` is enabled and `sat` is negative.
+ #[inline]
+ fn from_arithmetic(sat: bindings::ktime_t, wrap: bindings::ktime_t) -> Self {
+ #[cfg(CONFIG_RUST_OVERFLOW_CHECKS)]
+ {
+ let _ = wrap;
+ // INVARIANT: With overflow checks enabled, we verify here that the value is >= 0.
+ // An overflow above `KTIME_MAX` already panicked in the caller.
+ assert!(sat >= 0);
+
+ Self {
+ inner: sat,
+ _c: PhantomData,
+ }
+ }
+
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ {
+ // INVARIANT: Without overflow checks, clamp into `0..=KTIME_MAX` and warn once when
+ // the raw operation would have left that range.
+ let inner = if sat != wrap || sat < 0 {
+ crate::pr_warn_once!(
+ "Instant arithmetic produced an out-of-range value, clamping\n"
+ );
+ if sat < 0 { 0 } else { sat }
+ } else {
+ sat
+ };
+
+ Self {
+ inner,
+ _c: PhantomData,
+ }
+ }
+ }
}
impl<C: ClockId> ops::Sub for Instant<C, Nsec> {
@@ -273,40 +318,56 @@ fn sub(self, other: Instant<C>) -> Delta {
impl<T: ClockId> ops::Add<Delta> for Instant<T, Nsec> {
type Output = Self;
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_OVERFLOW_CHECKS` is enabled and the result is negative or greater
+ /// than `KTIME_MAX`.
+ ///
+ /// Otherwise, the result is clamped to the range from 0 to `KTIME_MAX` and a warning is
+ /// printed once.
#[inline]
fn add(self, rhs: Delta) -> Self::Output {
- // INVARIANT: With arithmetic over/underflow checks enabled, this will panic if we overflow
- // (e.g. go above `KTIME_MAX`)
- let res = self.inner + rhs.value;
-
- // INVARIANT: With overflow checks enabled, we verify here that the value is >= 0
#[cfg(CONFIG_RUST_OVERFLOW_CHECKS)]
- assert!(res >= 0);
+ // With overflow checks enabled, this panics if we overflow (e.g. go above `KTIME_MAX`).
+ let (sat, wrap) = {
+ let res = self.inner + rhs.value;
+ (res, res)
+ };
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ let (sat, wrap) = (
+ self.inner.saturating_add(rhs.value),
+ self.inner.wrapping_add(rhs.value),
+ );
- Self {
- inner: res,
- _c: PhantomData,
- }
+ Self::from_arithmetic(sat, wrap)
}
}
impl<T: ClockId> ops::Sub<Delta> for Instant<T, Nsec> {
type Output = Self;
+ /// # Panics
+ ///
+ /// Panics if `CONFIG_RUST_OVERFLOW_CHECKS` is enabled and the result is negative or greater
+ /// than `KTIME_MAX`.
+ ///
+ /// Otherwise, the result is clamped to the range from 0 to `KTIME_MAX` and a warning is
+ /// printed once.
#[inline]
fn sub(self, rhs: Delta) -> Self::Output {
- // INVARIANT: With arithmetic over/underflow checks enabled, this will panic if we overflow
- // (e.g. go above `KTIME_MAX`)
- let res = self.inner - rhs.value;
-
- // INVARIANT: With overflow checks enabled, we verify here that the value is >= 0
#[cfg(CONFIG_RUST_OVERFLOW_CHECKS)]
- assert!(res >= 0);
+ // With overflow checks enabled, this panics if we overflow (e.g. go above `KTIME_MAX`).
+ let (sat, wrap) = {
+ let res = self.inner - rhs.value;
+ (res, res)
+ };
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ let (sat, wrap) = (
+ self.inner.saturating_sub(rhs.value),
+ self.inner.wrapping_sub(rhs.value),
+ );
- Self {
- inner: res,
- _c: PhantomData,
- }
+ Self::from_arithmetic(sat, wrap)
}
}
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping
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 ` Franklin-Qi
2026-12-04 10:38 ` FUJITA Tomonori
2026-12-05 9:55 ` kernel test robot
1 sibling, 2 replies; 6+ messages in thread
From: Franklin-Qi @ 2026-12-04 9:29 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
Add KUnit coverage for Instant + Delta and Instant - Delta after the
invariant-preserving arithmetic change.
Test an in-range add/sub path, and the clamping paths used when
CONFIG_RUST_OVERFLOW_CHECKS is disabled: a result below 0 clamps to 0,
and a result above KTIME_MAX (i64::MAX) saturates at KTIME_MAX. The
out-of-range panic paths under overflow checks are left for later
should_panic support.
Build the Instant fixtures through Instant::from_ktime() so the tests
use the same debug_assert!-checked constructor as the rest of the crate,
instead of writing the private fields directly. Restore that constructor
for the tests, and static_assert that ktime_t::MAX matches i64::MAX
(KTIME_MAX).
Suggested-by: Andreas Hindborg <a.hindborg@kernel.org>
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Franklin-Qi <yusq77@gmail.com>
---
Changes in v4:
- Use Instant::from_ktime() in the KUnit helper (Miguel).
- Restore from_ktime() with debug_assert! and
static_assert!(bindings::ktime_t::MAX == i64::MAX). bindings::KTIME_MAX
is not currently exported; this asserts the same upper bound.
- expect(dead_code) on from_ktime() when CONFIG_RUST_TIME_KUNIT_TEST=n.
Changes in v3:
- Add KUnit tests for in-range Instant±Delta and the nochecks clamping
paths (Andreas, Miguel).
v1: https://lore.kernel.org/rust-for-linux/179610727734.137620.3884652165779521586@gmail.com/
v2: https://lore.kernel.org/rust-for-linux/20261202080227.898512-1-yusq77@gmail.com/
v3: https://lore.kernel.org/rust-for-linux/20261203092101.63850-3-yusq77@gmail.com/
rust/kernel/time.rs | 75 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
index 4ff65c74b5b5..a9b781753d9e 100644
--- a/rust/kernel/time.rs
+++ b/rust/kernel/time.rs
@@ -257,6 +257,31 @@ pub(crate) fn as_nanos(&self) -> i64 {
self.inner
}
+ /// Create an [`Instant`] from a `ktime_t` without checking if it is non-negative.
+ ///
+ /// # Panics
+ ///
+ /// On debug builds, this function will panic if `ktime` is not in the range from 0 to
+ /// `KTIME_MAX`.
+ ///
+ /// # Safety
+ ///
+ /// The caller promises that `ktime` is in the range from 0 to `KTIME_MAX`.
+ #[cfg_attr(not(CONFIG_RUST_TIME_KUNIT_TEST), expect(dead_code))]
+ #[inline]
+ pub(crate) unsafe fn from_ktime(ktime: bindings::ktime_t) -> Self {
+ // Instant's upper bound is `KTIME_MAX`, which equals `i64::MAX` / `ktime_t::MAX`.
+ crate::static_assert!(bindings::ktime_t::MAX == i64::MAX);
+ debug_assert!(ktime >= 0);
+
+ // INVARIANT: Our safety contract ensures that `ktime` is in the range from 0 to
+ // `KTIME_MAX`.
+ Self {
+ inner: ktime,
+ _c: PhantomData,
+ }
+ }
+
/// Create an [`Instant`] from the result of an arithmetic operation.
///
/// With overflow checks disabled, `sat` is the saturating result and `wrap` is the wrapping
@@ -1010,4 +1035,54 @@ fn to_jiffies_timeout_saturates() {
let negative = Delta::from_nanos(i64::MIN).to_jiffies_timeout();
assert_eq!(negative.as_jiffies(), 0);
}
+
+ /// Build an [`Instant`] with a chosen nanosecond value for boundary tests.
+ ///
+ /// `ns` must be in `0..=KTIME_MAX` (`i64::MAX`).
+ fn instant_at(ns: i64) -> Instant<Monotonic> {
+ // SAFETY: `ns` is in `0..=KTIME_MAX` by the helper contract above.
+ unsafe { Instant::from_ktime(ns) }
+ }
+
+ #[test]
+ fn instant_add_sub_delta_in_range() {
+ let t = instant_at(NSEC_PER_SEC);
+
+ assert_eq!((t + Delta::from_secs(1)).as_nanos(), 2 * NSEC_PER_SEC);
+ assert_eq!((t - Delta::from_secs(1)).as_nanos(), 0);
+ }
+
+ // Clamping only applies when overflow checks are disabled; with them enabled the
+ // out-of-range cases panic instead (covered manually / once `should_panic` lands).
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ #[test]
+ fn instant_add_clamps_above_ktime_max() {
+ let t = instant_at(i64::MAX);
+
+ assert_eq!((t + Delta::from_nanos(1)).as_nanos(), i64::MAX);
+ }
+
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ #[test]
+ fn instant_sub_clamps_below_zero() {
+ let t = instant_at(0);
+
+ assert_eq!((t - Delta::from_nanos(1)).as_nanos(), 0);
+ }
+
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ #[test]
+ fn instant_add_negative_delta_clamps_below_zero() {
+ let t = instant_at(5);
+
+ assert_eq!((t + Delta::from_nanos(-10)).as_nanos(), 0);
+ }
+
+ #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
+ #[test]
+ fn instant_sub_negative_delta_clamps_above_ktime_max() {
+ let t = instant_at(i64::MAX);
+
+ assert_eq!((t - Delta::from_nanos(-1)).as_nanos(), i64::MAX);
+ }
}
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/2] rust: time: keep Instant invariant when adding/subtracting Delta
2026-12-04 9:28 ` [PATCH v4 1/2] " Franklin-Qi
@ 2026-12-04 10:07 ` FUJITA Tomonori
0 siblings, 0 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2026-12-04 10:07 UTC (permalink / raw)
To: yusq77
Cc: a.hindborg, lyude, ojeda, aliceryhl, fujita.tomonori, boqun, dakr,
rust-for-linux, tglx, jstultz, sboyd, frederic, anna-maria,
georgeandrout13, stable
On Fri, 4 Dec 2026 17:28:43 +0800
Franklin-Qi <yusq77@gmail.com> wrote:
> @@ -256,6 +256,51 @@ pub fn elapsed(&self) -> Delta {
> pub(crate) fn as_nanos(&self) -> i64 {
> self.inner
> }
> +
> + /// Create an [`Instant`] from the result of an arithmetic operation.
> + ///
> + /// With overflow checks disabled, `sat` is the saturating result and `wrap` is the wrapping
> + /// result of the same operation. A mismatch means the `i64` range was exceeded; a negative
> + /// `sat` means the result fell below 0. Both cases print a warning once and clamp into
> + /// `0..=KTIME_MAX` (`KTIME_MAX` equals `i64::MAX`).
> + ///
> + /// # Panics
> + ///
> + /// Panics if `CONFIG_RUST_OVERFLOW_CHECKS` is enabled and `sat` is negative.
> + #[inline]
> + fn from_arithmetic(sat: bindings::ktime_t, wrap: bindings::ktime_t) -> Self {
> + #[cfg(CONFIG_RUST_OVERFLOW_CHECKS)]
> + {
> + let _ = wrap;
> + // INVARIANT: With overflow checks enabled, we verify here that the value is >= 0.
> + // An overflow above `KTIME_MAX` already panicked in the caller.
> + assert!(sat >= 0);
> +
> + Self {
> + inner: sat,
> + _c: PhantomData,
> + }
> + }
> +
> + #[cfg(not(CONFIG_RUST_OVERFLOW_CHECKS))]
> + {
> + // INVARIANT: Without overflow checks, clamp into `0..=KTIME_MAX` and warn once when
> + // the raw operation would have left that range.
> + let inner = if sat != wrap || sat < 0 {
> + crate::pr_warn_once!(
> + "Instant arithmetic produced an out-of-range value, clamping\n"
> + );
> + if sat < 0 { 0 } else { sat }
> + } else {
> + sat
> + };
> +
> + Self {
> + inner,
> + _c: PhantomData,
> + }
> + }
> + }
> }
I think sashiko's comment on v3 [1] still applies. checked_add() and
checked_sub() would make this simpler. Something like:
#[inline]
fn from_checked(res: Option<bindings::ktime_t>) -> Self {
// The `Instant` operand is in `0..=KTIME_MAX`, so `None` means
// that the result went above `KTIME_MAX`.
let inner = match res {
Some(res) if res >= 0 => res,
_ if cfg!(CONFIG_RUST_OVERFLOW_CHECKS) => {
panic!("Instant arithmetic produced an out-of-range value")
}
_ => {
crate::pr_warn_once!("Instant arithmetic produced an out-of-range value, clamping\n");
if res.is_none() {
bindings::ktime_t::MAX
} else {
0
}
}
};
// INVARIANT: `inner` is in the range from 0 to `KTIME_MAX`.
Self {
inner,
_c: PhantomData,
}
}
fn add(self, rhs: Delta) -> Self::Output {
Self::from_checked(self.inner.checked_add(rhs.value))
}
fn sub(self, rhs: Delta) -> Self::Output {
Self::from_checked(self.inner.checked_sub(rhs.value))
}
With overflow checks, both cases still panic.
[1] https://sashiko.dev/#/patchset/20261203092101.63850-1-yusq77%40gmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping
2026-12-04 9:29 ` [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping Franklin-Qi
@ 2026-12-04 10:38 ` FUJITA Tomonori
2026-12-05 9:55 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2026-12-04 10:38 UTC (permalink / raw)
To: yusq77
Cc: a.hindborg, lyude, ojeda, aliceryhl, fujita.tomonori, boqun, dakr,
rust-for-linux, tglx, jstultz, sboyd, frederic, anna-maria,
georgeandrout13, stable
On Fri, 4 Dec 2026 17:29:10 +0800
Franklin-Qi <yusq77@gmail.com> wrote:
> + /// Create an [`Instant`] from a `ktime_t` without checking if it is non-negative.
> + ///
> + /// # Panics
> + ///
> + /// On debug builds, this function will panic if `ktime` is not in the range from 0 to
> + /// `KTIME_MAX`.
> + ///
> + /// # Safety
> + ///
> + /// The caller promises that `ktime` is in the range from 0 to `KTIME_MAX`.
> + #[cfg_attr(not(CONFIG_RUST_TIME_KUNIT_TEST), expect(dead_code))]
> + #[inline]
> + pub(crate) unsafe fn from_ktime(ktime: bindings::ktime_t) -> Self {
> + // Instant's upper bound is `KTIME_MAX`, which equals `i64::MAX` / `ktime_t::MAX`.
> + crate::static_assert!(bindings::ktime_t::MAX == i64::MAX);
> + debug_assert!(ktime >= 0);
> +
> + // INVARIANT: Our safety contract ensures that `ktime` is in the range from 0 to
> + // `KTIME_MAX`.
> + Self {
> + inner: ktime,
> + _c: PhantomData,
> + }
> + }
from_ktime() was removed in timekeeping-next by commit 6b391eec2dde
("rust: hrtimer: Remove HrTimer::expires()") because it had no users.
It is still in mainline and rust-next. This patch adds it back only
for the tests.
As sashiko reports on v4 [1], with CONFIG_KUNIT=m and CONFIG_WERROR=y,
the build fails because from_ktime() is never used. I confirmed this.
Since it is only for the tests, I think it is simpler to build the
Instant in instant_at() in the tests module, as v3 did, with a
core::assert!() check of ns and an INVARIANT comment. That also fixes
the dead_code error and the unsafe issue.
[1] https://sashiko.dev/#/patchset/20261204083408.229840-1-yusq77%40gmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping
2026-12-04 9:29 ` [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping Franklin-Qi
2026-12-04 10:38 ` FUJITA Tomonori
@ 2026-12-05 9:55 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-12-05 9:55 UTC (permalink / raw)
To: Franklin-Qi, Andreas Hindborg, Lyude Paul, Miguel Ojeda,
Alice Ryhl
Cc: llvm, oe-kbuild-all, 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 Franklin-Qi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rust/timekeeping-next]
[also build test WARNING on next-20261203]
[cannot apply to ah-configfs/configfs-next rust/rust-next linus/master v7.4-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Franklin-Qi/rust-time-keep-Instant-invariant-when-adding-subtracting-Delta/20261204-172843
base: https://github.com/Rust-for-Linux/linux timekeeping-next
patch link: https://lore.kernel.org/r/20261204092910.253781-1-yusq77%40gmail.com
patch subject: [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping
config: um-allmodconfig (https://download.01.org/0day-ci/archive/20261205/20261205123820.8Vmtiora-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
rustc: rustc 1.96.0 (ac68faa20 2026-05-25)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205123820.8Vmtiora-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261205123820.8Vmtiora-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> warning: associated function `from_ktime` is never used
--> rust/kernel/time.rs:272:26
|
248 | impl<C: ClockId> Instant<C, Nsec> {
| --------------------------------- associated function in this implementation
...
272 | pub(crate) unsafe fn from_ktime(ktime: bindings::ktime_t) -> Self {
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
--
In file included from kernel/sched/rq-offsets.c:5:
In file included from kernel/sched/sched.h:28:
In file included from include/linux/cgroup_api.h:1:
In file included from include/linux/cgroup.h:27:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:24:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:12:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1209 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^
1 warning generated.
llvm-nm: error: rust/helpers/helpers.o: No such file or directory
clang diag: include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
clang diag: include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
clang diag: include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> warning: associated function `from_ktime` is never used
--> rust/kernel/time.rs:272:26
|
248 | impl<C: ClockId> Instant<C, Nsec> {
| --------------------------------- associated function in this implementation
...
272 | pub(crate) unsafe fn from_ktime(ktime: bindings::ktime_t) -> Self {
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-05 9:56 UTC | newest]
Thread overview: 6+ 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 10:07 ` FUJITA Tomonori
2026-12-04 9:29 ` [PATCH v4 2/2] rust: time: add KUnit tests for Instant Delta clamping Franklin-Qi
2026-12-04 10:38 ` FUJITA Tomonori
2026-12-05 9:55 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox