All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Trevor Chan <trev@trevrosa.dev>
Cc: alex.gaynor@gmail.com, ojeda@kernel.org,
	gregkh@linuxfoundation.org,  rafael@kernel.org, dakr@kernel.org,
	airlied@gmail.com, simona@ffwll.ch,  vireshk@kernel.org,
	nm@ti.com, sboyd@kernel.org, viro@zeniv.linux.org.uk,
	 brauner@kernel.org, boqun.feng@gmail.com, gary@garyguo.net,
	 bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org,  tmgross@umich.edu,
	rust-for-linux@vger.kernel.org, david.m.ertman@intel.com,
	 ira.weiny@intel.com, leon@kernel.org,
	lorenzo.stoakes@oracle.com,  Liam.Howlett@oracle.com,
	bhelgaas@google.com, kwilczynski@kernel.org,  jack@suse.cz
Subject: Re: [PATCH v2] rust: aref: make `AlwaysRefCounted::inc_ref` an associated function
Date: Tue, 2 Sep 2025 09:29:48 +0000	[thread overview]
Message-ID: <aLa5DIMV-ADsw2c6@google.com> (raw)
In-Reply-To: <20250902090638.785-1-trev@trevrosa.dev>

On Tue, Sep 02, 2025 at 05:06:38PM +0800, Trevor Chan wrote:
> `AlwaysRefCounted::inc_ref` is a function that shouldn't be called lightly.
> 
> To prevent accidentally calling it, `inc_ref` is now changed to be an
> associated function.
> 
> Modifies all `AlwaysRefCounted` implementors to work with this change.
> 
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1177
> Signed-off-by: Trevor Chan <trev@trevrosa.dev>

One nit below, but:

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

> diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs
> index dbd77bb68617..3a3d5052786c 100644
> --- a/rust/kernel/sync/aref.rs
> +++ b/rust/kernel/sync/aref.rs
> @@ -24,7 +24,9 @@
>  /// alive.)
>  pub unsafe trait AlwaysRefCounted {
>      /// Increments the reference count on the object.
> -    fn inc_ref(&self);
> +    ///
> +    /// This function should not be called lightly.
> +    fn inc_ref(obj: &Self);
>  
>      /// Decrements the reference count on the object.
>      ///
> @@ -103,7 +105,7 @@ pub unsafe fn from_raw(ptr: NonNull<T>) -> Self {
>      ///
>      /// # // SAFETY: TODO.
>      /// unsafe impl AlwaysRefCounted for Empty {
> -    ///     fn inc_ref(&self) {}
> +    ///     fn inc_ref(obj: &Self) {}
>      ///     unsafe fn dec_ref(_obj: NonNull<Self>) {}

We probably want _obj for inc_ref like we have for dec_ref.

Alice

      parent reply	other threads:[~2025-09-02  9:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  9:06 [PATCH v2] rust: aref: make `AlwaysRefCounted::inc_ref` an associated function Trevor Chan
2025-09-02  9:20 ` Viresh Kumar
2025-09-02  9:29 ` Alice Ryhl [this message]

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=aLa5DIMV-ADsw2c6@google.com \
    --to=aliceryhl@google.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=airlied@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brauner@kernel.org \
    --cc=dakr@kernel.org \
    --cc=david.m.ertman@intel.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=ira.weiny@intel.com \
    --cc=jack@suse.cz \
    --cc=kwilczynski@kernel.org \
    --cc=leon@kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=nm@ti.com \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    --cc=trev@trevrosa.dev \
    --cc=vireshk@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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.