All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Philipp Stanner" <phasta@kernel.org>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org
Subject: Re: [PATCH v3 1/4] rust: types: implement ForeignOwnable for ARef<T>
Date: Tue, 23 Jun 2026 20:18:56 +0000	[thread overview]
Message-ID: <20260623201856.8CBAE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260618132628.3811068-3-phasta@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing `#[inline]` annotations on small abstraction functions in `ForeignOwnable for ARef<T>`.
--

commit 4199b74db0ae4068188998ff9452d6df8acb7816
Author: Danilo Krummrich <dakr@kernel.org>

rust: types: implement ForeignOwnable for ARef<T>

Implement ForeignOwnable for ARef<T>, making it possible for C code to
own an ARef<T>.

> diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs
> --- a/rust/kernel/sync/aref.rs
> +++ b/rust/kernel/sync/aref.rs

[ ... ]

> +unsafe impl<T: AlwaysRefCounted + 'static> ForeignOwnable for ARef<T> {
> +    const FOREIGN_ALIGN: usize = core::mem::align_of::<T>();
> +
> +    type Borrowed<'a> = &'a T;
> +    type BorrowedMut<'a> = &'a T;
> +
> +    fn into_foreign(self) -> *mut c_void {
> +        ARef::into_raw(self).as_ptr().cast()
> +    }
> +
> +    unsafe fn from_foreign(ptr: *mut c_void) -> Self {
> +        // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
> +        // call to `Self::into_foreign`.
> +        let ptr = unsafe { NonNull::new_unchecked(ptr.cast()) };
> +
> +        // SAFETY: `ptr` came from `into_foreign`, which consumed an `ARef` without decrementing
> +        // the refcount, so we can transfer the ownership to the new `ARef`.
> +        unsafe { ARef::from_raw(ptr) }
> +    }

[Severity: Low]
This isn't a bug, but should into_foreign() and from_foreign() be annotated 
with #[inline]? 

Since aref.rs is a core abstraction, the Rust coding guidelines suggest adding 
the inline annotation to small or forwarding functions to help with cross-crate 
inlining optimizations. Would it make sense to add this to borrow() and 
borrow_mut() in this block as well?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260618132628.3811068-2-phasta@kernel.org?part=1

  reply	other threads:[~2026-06-23 20:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 13:26 [PATCH v3 0/4] rust / dma_buf: Add abstractions for dma_fence Philipp Stanner
2026-06-18 13:26 ` [PATCH v3 1/4] rust: types: implement ForeignOwnable for ARef<T> Philipp Stanner
2026-06-23 20:18   ` sashiko-bot [this message]
2026-06-18 13:26 ` [PATCH v3 2/4] rust: error: Add ECANCELED error code Philipp Stanner
2026-06-18 19:14   ` Miguel Ojeda
2026-06-18 13:26 ` [PATCH v3 3/4] rust: Add dma_fence abstractions Philipp Stanner
2026-06-23 20:33   ` sashiko-bot
2026-06-18 13:26 ` [PATCH v3 4/4] MAINTAINERS: Add entry for Rust dma-buf Philipp Stanner
2026-06-18 13:30   ` Christian König
2026-06-18 15:07     ` Sumit Semwal

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=20260623201856.8CBAE1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=phasta@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.