[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878qv3pthd.fsf@kernel.org>
Date: Fri, 04 Oct 2024 21:18:22 +0200
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Gary Guo" <gary@...yguo.net>
Cc: "Boqun Feng" <boqun.feng@...il.com>, "Miguel Ojeda" <ojeda@...nel.org>,
"Alex Gaynor" <alex.gaynor@...il.com>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
"Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Jens Axboe" <axboe@...nel.dk>, "Will Deacon" <will@...nel.org>, "Peter
Zijlstra" <peterz@...radead.org>, "Mark Rutland" <mark.rutland@....com>,
<linux-block@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] rust: block: convert `block::mq` to use `Refcount`
"Gary Guo" <gary@...yguo.net> writes:
> On Fri, 04 Oct 2024 20:34:01 +0200
> Andreas Hindborg <a.hindborg@...nel.org> wrote:
>
>> Hi Gary,
>>
>> "Gary Guo" <gary@...yguo.net> writes:
>>
>> [...]
>>
>> > // SAFETY: All instances of `Request<T>` are reference counted. This
>> > // implementation of `AlwaysRefCounted` ensure that increments to the ref count
>> > // keeps the object alive in memory at least until a matching reference count
>> > // decrement is executed.
>> > unsafe impl<T: Operations> AlwaysRefCounted for Request<T> {
>> > fn inc_ref(&self) {
>> > - let refcount = &self.wrapper_ref().refcount();
>> > -
>> > - #[cfg_attr(not(CONFIG_DEBUG_MISC), allow(unused_variables))]
>> > - let updated = atomic_relaxed_op_unless(refcount, |x| x + 1, 0);
>> > -
>> > - #[cfg(CONFIG_DEBUG_MISC)]
>> > - if !updated {
>> > - panic!("Request refcount zero on clone")
>> > - }
>> > + self.wrapper_ref().refcount().inc();
>>
>> What happened to the debug code?
>>
>>
>> BR Andreas
>>
>
> `refcount_inc` will WARN and saturate the refcount when trying to
> increment from zero. This is true regardless of config.
>
> I've already captured this in `Refcount::inc` documentation.
I did not know. Thanks!
BR Andreas
Powered by blists - more mailing lists