* linux-next: manual merge of the rust-xarray tree with the rust-timekeeping tree
@ 2026-11-26 13:54 Mark Brown
0 siblings, 0 replies; only message in thread
From: Mark Brown @ 2026-11-26 13:54 UTC (permalink / raw)
To: Andreas Hindborg
Cc: FUJITA Tomonori, Linux Kernel Mailing List, Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 4533 bytes --]
Hi all,
Today's linux-next merge of the rust-xarray tree got a conflict in:
rust/kernel/time/hrtimer.rs
between commits:
8a914f7625e4e ("rust: time: remove leftover "clock source" wording from doc comments")
6b391eec2ddeb ("rust: hrtimer: Remove HrTimer::expires()")
from the rust-timekeeping tree and commit:
5c057c3a0b980 ("rust: hrtimer: add active() method to query timer state")
from the rust-xarray tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --cc rust/kernel/time/hrtimer.rs
index d1ca2441f9bbf,e960821ace3bd..0000000000000
--- a/rust/kernel/time/hrtimer.rs
+++ b/rust/kernel/time/hrtimer.rs
@@@ -569,6 -572,91 +571,68 @@@ impl<T> HrTimer<T>
{
self.forward(HrTimerInstant::<T>::now(), interval)
}
+
- /// Return the time expiry for this [`HrTimer`].
- ///
- /// This value should only be used as a snapshot, as the actual expiry time could change after
- /// this function is called.
- pub fn expires(&self) -> HrTimerInstant<T>
- where
- T: HasHrTimer<T>,
- {
- // SAFETY: `self` is an immutable reference and thus always points to a valid `HrTimer`.
- let c_timer_ptr = unsafe { HrTimer::raw_get(self) };
-
- // SAFETY:
- // - Timers cannot have negative ktime_t values as their expiration time.
- // - There's no actual locking here, a racy read is fine and expected
- unsafe {
- Instant::from_ktime(
- // This `read_volatile` is intended to correspond to a READ_ONCE call.
- // FIXME(read_once): Replace with `read_once` when available on the Rust side.
- core::ptr::read_volatile(&raw const ((*c_timer_ptr).node.expires)),
- )
- }
- }
-
+ /// Query the state of the timer.
+ ///
+ /// Returns [`true`] if the timer is in the started or running states.
+ ///
+ /// This method synchronizes internally and does not require exclusive access to the timer.
+ ///
+ /// The returned value is a snapshot. A concurrent event can change the state of the timer
+ /// right after this method returns, so callers that need the state to be stable must serialize
+ /// against such events by other means.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use kernel::{
+ /// # impl_has_hr_timer,
+ /// # prelude::*,
+ /// # time::{
+ /// # hrtimer::{
+ /// # HasHrTimer, HrTimer, HrTimerCallback, HrTimerCallbackContext,
+ /// # HrTimerRestart, RelativeMode,
+ /// # },
+ /// # Monotonic,
+ /// # },
+ /// # };
+ /// # use pin_init::stack_pin_init;
+ /// #[pin_data]
+ /// struct ExampleTimer {
+ /// #[pin]
+ /// timer: HrTimer<Self>,
+ /// }
+ ///
+ /// impl ExampleTimer {
+ /// fn new() -> impl PinInit<Self> {
+ /// pin_init!(Self { timer <- HrTimer::new() })
+ /// }
+ /// }
+ ///
+ /// impl HrTimerCallback for ExampleTimer {
+ /// type Pointer<'a> = Pin<&'a Self>;
+ /// fn run(_this: Pin<&Self>, _ctx: HrTimerCallbackContext<'_, Self>) -> HrTimerRestart {
+ /// HrTimerRestart::NoRestart
+ /// }
+ /// }
+ ///
+ /// impl_has_hr_timer! {
+ /// impl HasHrTimer<Self> for ExampleTimer {
+ /// mode: RelativeMode<Monotonic>, field: self.timer
+ /// }
+ /// }
+ ///
+ /// stack_pin_init!(let has_timer = ExampleTimer::new());
+ /// assert!(!has_timer.timer.active());
+ /// # Ok::<(), kernel::error::Error>(())
+ /// ```
+ #[inline]
+ pub fn active(&self) -> bool {
+ // SAFETY: By type invariant, `self.timer` is valid. `hrtimer_active`
+ // synchronizes internally and is safe to call without exclusive
+ // access to the timer.
+ unsafe { bindings::hrtimer_active(self.timer.get()) }
+ }
}
/// Implemented by pointer types that point to structs that contain a [`HrTimer`].
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-26 13:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 13:54 linux-next: manual merge of the rust-xarray tree with the rust-timekeeping tree Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®