[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DG0AHQVQUI2F.3559P1PRPJTVV@garyguo.net>
Date: Wed, 28 Jan 2026 14:24:46 +0000
From: "Gary Guo" <gary@...yguo.net>
To: "Andreas Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl"
<aliceryhl@...gle.com>
Cc: "Will Deacon" <will@...nel.org>, "Peter Zijlstra"
<peterz@...radead.org>, "Boqun Feng" <boqun.feng@...il.com>, "Mark Rutland"
<mark.rutland@....com>, "Gary Guo" <gary@...yguo.net>, "Miguel Ojeda"
<ojeda@...nel.org>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Trevor
Gross" <tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>,
<linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH] rust: atomic: add fetch_sub
On Wed Jan 28, 2026 at 2:16 PM GMT, Andreas Hindborg wrote:
> "Alice Ryhl" <aliceryhl@...gle.com> writes:
>
>> On Wed, Jan 28, 2026 at 01:47:11PM +0100, Andreas Hindborg wrote:
>>> Add `Atomic::fetch_sub` with implementation and documentation in line with
>>> existing `Atomic::fetch_add` implementation.
>>>
>>> Signed-off-by: Andreas Hindborg <a.hindborg@...nel.org>
>>
>>> + /// let x = Atomic::new(42);
>>> + ///
>>> + /// assert_eq!(42, x.load(Relaxed));
>>> + ///
>>> + /// assert_eq!(30, { x.fetch_sub(12, Acquire); x.load(Relaxed) });
>>
>> These asserts are a bit confusing to read. After all, the fetch_sub call
>> also returns a value, so how about this?
>>
>> let x = Atomic::new(42);
>> assert_eq!(42, x.load(Relaxed));
>> assert_eq!(42, x.fetch_sub(12, Acquire));
>> assert_eq!(30, x.load(Relaxed));
>
> We can do that. I basically copied the docs from add. Should I change
> those as well?
Please do. I also find that the existing example has too many line breaks :)
Something compact as what Alice suggested would be nice.
Best,
Gary
>
> Best regards,
> Andreas Hindborg
Powered by blists - more mailing lists