dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andreas Hindborg" <a.hindborg@kernel.org>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	ojeda@kernel.org
Subject: Re: [PATCH 4/6] rust: hrtimer: restrict expires() to exclusive access
Date: Tue, 25 Aug 2026 12:25:41 +0000	[thread overview]
Message-ID: <20260825122541.960DE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825-expires-v2-v1-4-90411c6217c7@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly introduced `expires_unchecked` method is private, making it inaccessible outside the module and defeating its documented purpose.
--

--- Patch [4]: [PATCH 4/6] rust: hrtimer: restrict expires() to exclusive access ---
commit eb28ef35be5861cd1df93f56841e97d8fd3ed101
Author: FUJITA Tomonori <fujita.tomonori@gmail.com>

rust: hrtimer: restrict expires() to exclusive access

This commit changes HrTimer::expires() to require exclusive access via
Pin<&mut Self> to prevent unsynchronized reads. It routes the read through
a new C helper and introduces an unsafe expires_unchecked() method for
contexts guaranteeing exclusive access externally.

Link: https://lore.kernel.org/r/20260813134834.1562995-4-tomo@flapping.org

> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
> index e6570a6162035..bdb6aaa228396 100644
> --- a/rust/kernel/time/hrtimer.rs
> +++ b/rust/kernel/time/hrtimer.rs

[ ... ]

> @@ -567,27 +567,36 @@ pub fn forward_now(self: Pin<&mut Self>, interval: Delta) -> u64
>          self.forward(HrTimerInstant::<T>::now(), interval)
>      }
>  
> +    /// Return the time expiry for this [`HrTimer`].
> +    ///
> +    /// # Safety
> +    ///
> +    /// The caller must have exclusive access to `self`.
> +    #[inline]
> +    unsafe fn expires_unchecked(&self) -> HrTimerInstant<T>

[Severity: Medium]
Will this method be usable by external modules or drivers? 

The commit message states the intent is to provide expires_unchecked() for
contexts that can guarantee exclusive access by other means.

Since it is missing the pub visibility modifier, it appears to be private
to the hrtimer module and inaccessible to other Rust code that might need it.

> +    where
> +        T: HasHrTimer<T>,
> +    {
> +        // SAFETY:
> +        // - The C API requirements for this function are fulfilled by our safety contract.
> +        // - Timers cannot have negative `ktime_t` values as their expiration time.
> +        unsafe { Instant::from_ktime(bindings::hrtimer_get_expires(Self::raw_get(self))) }
> +    }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260825-expires-v2-v1-0-90411c6217c7@kernel.org?part=4

  reply	other threads:[~2026-08-25 12:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 12:16 [PATCH 0/6] hrtimer: add an expiry injecting callback variant Andreas Hindborg
2026-08-25 12:16 ` [PATCH 1/6] hrtimer: add " Andreas Hindborg
2026-08-25 12:16 ` [PATCH 2/6] drm/i915/pmu: use the expiry injecting hrtimer callback Andreas Hindborg
2026-08-25 12:29   ` sashiko-bot
2026-08-25 12:16 ` [PATCH 3/6] rust: hrtimer: use the expiry injecting callback variant Andreas Hindborg
2026-08-25 12:33   ` sashiko-bot
2026-08-25 12:16 ` [PATCH 4/6] rust: hrtimer: restrict expires() to exclusive access Andreas Hindborg
2026-08-25 12:25   ` sashiko-bot [this message]
2026-08-25 12:16 ` [PATCH 5/6] rust: hrtimer: document deadlock when starting a timer in its handler Andreas Hindborg
2026-08-25 12:26   ` sashiko-bot
2026-08-25 13:31   ` Gary Guo
2026-08-26  9:31     ` Andreas Hindborg
2026-08-25 12:16 ` [PATCH 6/6] rust: hrtimer: Make HrTimer repr(transparent) Andreas Hindborg
2026-08-25 12:30   ` sashiko-bot
2026-08-25 13:33   ` Gary Guo
2026-08-26  9:30     ` Andreas Hindborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260825122541.960DE1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).