All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Philipp Stanner" <phasta@kernel.org>
Cc: linux-media@vger.kernel.org, ojeda@kernel.org
Subject: Re: [PATCH 1/4] rust: types: implement ForeignOwnable for ARef<T>
Date: Sat, 30 May 2026 14:45:38 +0000	[thread overview]
Message-ID: <20260530144538.DF3EA1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260530143541.229628-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 forwarding trait methods in `ForeignOwnable` implementation for `ARef<T>`.
--

commit 62543d419c62c8206acbd8b76f07e5198b71442e
Author: Danilo Krummrich <dakr@kernel.org>

rust: types: implement ForeignOwnable for ARef<T>

This commit implements ForeignOwnable for ARef<T>, making it possible for C
code to own an ARef<T>. It sets BorrowedMut to &T to match the shared
ownership semantics of the underlying reference-counted type.

> diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs
> index 9989f56d06052..82907383c44b5 100644
> --- a/rust/kernel/sync/aref.rs
> +++ b/rust/kernel/sync/aref.rs

[ ... ]

> +    type Borrowed<'a> = &'a T;
> +    type BorrowedMut<'a> = &'a T;
> +
> +    fn into_foreign(self) -> *mut c_void {

[Severity: Low]
This isn't a bug, but should this method be annotated with #[inline]?
According to the Rust subsystem guidelines, small forwarding functions in
abstractions should be annotated with #[inline].

> +        ARef::into_raw(self).as_ptr().cast()
> +    }
> +
> +    unsafe fn from_foreign(ptr: *mut c_void) -> Self {

[Severity: Low]
This isn't a bug, but should from_foreign() also have an #[inline]
annotation since it is a small wrapper method?

> +        // 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) }
> +    }
> +
> +    unsafe fn borrow<'a>(ptr: *mut c_void) -> &'a T {

[Severity: Low]
This isn't a bug, but similar to the above, should borrow() be annotated
with #[inline]?

> +        // SAFETY: The safety requirements of this method ensure that the object remains alive and
> +        // immutable for the duration of 'a.
> +        unsafe { &*ptr.cast() }
> +    }
> +
> +    unsafe fn borrow_mut<'a>(ptr: *mut c_void) -> &'a T {

[Severity: Low]
This isn't a bug, but does borrow_mut() need an #[inline] annotation here
as well?

> +        // SAFETY: The safety requirements for `borrow_mut` are a superset of the safety
> +        // requirements for `borrow`.
> +        unsafe { <Self as ForeignOwnable>::borrow(ptr) }
> +    }
> +}

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

  reply	other threads:[~2026-05-30 14:45 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-30 14:35 [PATCH 0/4] rust / dma_buf: Add abstractions for dma_fence Philipp Stanner
2026-05-30 14:35 ` [PATCH 1/4] rust: types: implement ForeignOwnable for ARef<T> Philipp Stanner
2026-05-30 14:45   ` sashiko-bot [this message]
2026-06-01  9:46   ` Alice Ryhl
2026-05-30 14:35 ` [PATCH 2/4] rust: rcu: add RcuBox type Philipp Stanner
2026-05-30 14:54   ` sashiko-bot
2026-05-30 15:08   ` Boqun Feng
2026-05-30 15:27     ` Danilo Krummrich
2026-06-01  7:56     ` Philipp Stanner
2026-06-01 13:41       ` Boqun Feng
2026-06-03  9:33         ` Philipp Stanner
2026-06-03  9:35           ` Alice Ryhl
2026-06-03 15:27           ` Boqun Feng
2026-06-03 17:36             ` Boqun Feng
2026-06-03 17:07   ` Boqun Feng
2026-05-30 14:35 ` [PATCH 3/4] rust: Add dma_fence abstractions Philipp Stanner
2026-05-30 15:06   ` sashiko-bot
2026-06-01 10:20     ` Alice Ryhl
2026-06-01 12:34       ` Philipp Stanner
2026-06-01 12:55         ` Alice Ryhl
2026-06-01 13:14           ` Philipp Stanner
2026-06-01 13:30             ` Philipp Stanner
2026-06-01 13:54               ` Alice Ryhl
2026-06-01 13:44             ` Alice Ryhl
2026-06-02 11:31               ` Philipp Stanner
2026-06-02 11:44                 ` Alice Ryhl
2026-06-02 11:52                   ` Philipp Stanner
2026-06-02 11:59                     ` Alice Ryhl
2026-06-02 12:06                       ` Philipp Stanner
2026-06-02 15:25                         ` Alice Ryhl
2026-06-03  6:10                           ` Philipp Stanner
2026-06-03  6:48                             ` Boris Brezillon
2026-06-03  7:43                               ` Philipp Stanner
2026-06-03  9:07                                 ` Philipp Stanner
2026-06-03  9:26                                   ` Alice Ryhl
2026-06-03  9:36                                     ` Philipp Stanner
2026-06-03  9:52                                 ` Boris Brezillon
2026-06-03  9:58                                   ` Boris Brezillon
2026-06-03 10:07                                     ` Philipp Stanner
2026-06-03 11:22                                       ` Boris Brezillon
2026-06-03 11:49                                         ` Philipp Stanner
2026-06-03 13:35                                           ` Boris Brezillon
2026-06-03 15:57                                         ` Danilo Krummrich
2026-06-03 16:34                                           ` Boris Brezillon
2026-06-03 19:43                                             ` Philipp Stanner
2026-06-03 16:51                                           ` Boris Brezillon
2026-05-30 15:16   ` Danilo Krummrich
2026-06-01  8:46     ` Philipp Stanner
2026-06-01 10:13       ` Danilo Krummrich
2026-06-01 10:36   ` Alice Ryhl
2026-06-01 10:59     ` Boris Brezillon
2026-06-01 11:17       ` Philipp Stanner
2026-06-01 12:35         ` Boris Brezillon
2026-06-01 12:26     ` Philipp Stanner
2026-06-01 12:39       ` Alice Ryhl
2026-06-01 12:47         ` Philipp Stanner
2026-06-01 13:22           ` Alice Ryhl
2026-06-01 13:23             ` Philipp Stanner
2026-06-01 13:27               ` Alice Ryhl
2026-06-01 12:37     ` Boris Brezillon
2026-06-03 16:41   ` Daniel Almeida
2026-06-03 17:14     ` Boris Brezillon
2026-06-04  0:43       ` Daniel Almeida
2026-06-04  8:15         ` Boris Brezillon
2026-06-05  7:56           ` Philipp Stanner
2026-06-05 16:00             ` Daniel Almeida
2026-06-05 16:02               ` Daniel Almeida
2026-06-05 15:51           ` Daniel Almeida
2026-05-30 14:35 ` [PATCH 4/4] MAINTAINERS: Add entry for Rust dma-buf Philipp Stanner
2026-05-30 15:20   ` Danilo Krummrich
2026-06-03 15:22 ` [PATCH 0/4] rust / dma_buf: Add abstractions for dma_fence Daniel Almeida

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=20260530144538.DF3EA1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-media@vger.kernel.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.