Re: [PATCH v5 4/5] rust: block: convert `block::mq` to use `Refcount`

From: Boqun Feng
Date: Mon Sep 01 2025 - 22:18:51 EST


On Thu, Aug 28, 2025 at 09:18:40AM +0200, Benno Lossin wrote:
> On Wed Aug 27, 2025 at 9:51 PM CEST, Gary Guo wrote:
> > On Tue, 12 Aug 2025 10:17:44 +0200
> > "Benno Lossin" <lossin@xxxxxxxxxx> wrote:
> >> On Thu Jul 24, 2025 at 1:32 AM CEST, Gary Guo wrote:
> >> > @@ -34,6 +36,18 @@ fn as_ptr(&self) -> *mut bindings::refcount_t {
> >> > self.0.get()
> >> > }
> >> >
> >> > + /// Get the underlying atomic counter that backs the refcount.
> >> > + ///
> >> > + /// NOTE: This will be changed to LKMM atomic in the future.
> >>
> >> Can we discourage using this function a bit more in the docs? At least
> >> point people to try other ways before reaching for this, since it allows
> >> overflowing & doesn't warn on saturate etc.
> >
> > Would this additional doc comment be good enough for you?
> >
> > /// NOTE: usage of this function is discouraged unless there is no way
> > /// to achieve the desired result using APIs in `refcount.h`. If an API
> > /// in `refcount.h` does not currently contain a binding, please
> > /// consider adding a binding for it instead.
>
> I'd like to stress that the atomic doesn't have the same protections as
> the refcount type, how about:
>
> /// NOTE: usage of this function is discouraged as it can circumvent the protections offered by
> /// `refcount.h`. If there is no way to achieve the result using APIs in `refcount.h`, then this
> /// function can be used. Otherwise consider adding a binding for the required API.
>

Looks good to me. I will apply this and some adjustment against my
atomic patchset, and queue this whole series for v6.18, thanks!

Regards,
Boqun

> ---
> Cheers,
> Benno