rust: time: Pass correct timer mode ID to hrtimer_start_range_ns
Subsystems (2)
Lyude Paul
reviewerPATCH 1/1 rust: time: Pass correct timer mode ID to hrtimer_start_range_ns
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.
--- rust/kernel/time/hrtimer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/time/hrtimer.rs +1 -1
@@ -398,7 +398,7 @@ unsafe fn start(this: *const Self, expires: <Self::TimerMode as HrTimerMode>::Ex Self::c_timer_ptr(this).cast_mut(), expires.as_nanos(), 0, - <Self::TimerMode as HrTimerMode>::Clock::ID as u32, + <Self::TimerMode as HrTimerMode>::C_MODE as u32 ); } }
base-commit: d4b29ddf82a458935f1bd4909b8a7a13df9d3bdc
Signature · 1 line
2.50.0
Quoted 8 lines · Lyude Paul
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 tohrtimer_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.
Quoted 5 lines
So, fix this by passing the ID for the timer mode instead.
Signed-off-by Lyude Paul <[email protected]>Cc FUJITA Tomonori <[email protected]>Fixes fcc1dd8c8656 ("rust: time: Make HasHrTimer generic over HrTimerMode")
Wow, thanks! Miguel, can you take this through rust-fixes?
Best regards,
Andreas Hindborg
FUJITA Tomonori
reviewerQuoted 10 lines · On Fri, 11 Jul 2025 08:18:37 +0200 Andreas Hindborg <[email protected]>…
Quoted 8 lines · Lyude Paul
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 tohrtimer_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.
Quoted 7 lines
Quoted 5 lines
So, fix this by passing the ID for the timer mode instead.
Signed-off-by Lyude Paul <[email protected]>Cc FUJITA Tomonori <[email protected]>Fixes fcc1dd8c8656 ("rust: time: Make HasHrTimer generic over HrTimerMode")Wow, thanks! Miguel, can you take this through rust-fixes?
I think that this patch fixes the commit in timekeeping-next.
fcc1dd8c8656 doesn't match to the commit in the current timekeeping-next (this patch might have been made against the tree before it was rebased).
Andreas Hindborg
maintainerQuoted 19 lines · FUJITA Tomonori
Quoted 16 lines · On Fri, 11 Jul 2025 08:18:37 +0200 Andreas Hindborg <[email protected]>…
Quoted 13 lines · Lyude Paul
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 tohrtimer_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 <[email protected]>Cc FUJITA Tomonori <[email protected]>Fixes fcc1dd8c8656 ("rust: time: Make HasHrTimer generic over HrTimerMode")
Quoted 7 lines
Quoted 1 line
Wow, thanks! Miguel, can you take this through rust-fixes?
I think that this patch fixes the commit in timekeeping-next.
fcc1dd8c8656doesn't match to the commit in the current timekeeping-next (this patch might have been made against the tree before it was rebased).
Maybe Miguel can put the correct hash when he applies the patch.
Best regards,
Andreas Hindborg
Quoted 2 lines · Andreas Hindborg
Maybe Miguel can put the correct hash when he applies the patch.
Sure:
Cheers,
Miguel
Quoted 8 lines · On Thu, 10 Jul 2025 18:51:13 -0400 Lyude Paul <[email protected]> wrote:
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 tohrtimer_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.
Quoted 8 lines
So, fix this by passing the ID for the timer mode instead.
Signed-off-by Lyude Paul <[email protected]>Cc FUJITA Tomonori <[email protected]>Fixes fcc1dd8c8656 ("rust: time: Make HasHrTimer generic over HrTimerMode")--- rust/kernel/time/hrtimer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Ah, my bad! Thanks a lot for the fix.
Quoted 9 lines · Lyude Paul
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 tohrtimer_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.
Quoted 5 lines
So, fix this by passing the ID for the timer mode instead.
Signed-off-by Lyude Paul <[email protected]>Cc FUJITA Tomonori <[email protected]>Fixes fcc1dd8c8656 ("rust: time: Make HasHrTimer generic over HrTimerMode")
Applied to rust-next (on top of the timekeeping merge) -- thanks everyone!
[ Removed cast, applied rustfmt, fixed Fixes: tag. - Miguel ]
I assume the cast was there just because the original line (Clock::ID) had it.
Cheers,
Miguel