From: Mark Rutland <mark.rutland@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Boqun Feng <boqun.feng@gmail.com>,
Will Deacon <will.deacon@arm.com>, Arnd Bergmann <arnd@arndb.de>,
Richard Henderson <rth@twiddle.net>,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Matt Turner <mattst88@gmail.com>,
Vineet Gupta <vgupta@synopsys.com>,
Russell King <linux@armlinux.org.uk>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Palmer Dabbelt <palmer@sifive.com>, Albert Ou <albert@sifive.com>
Subject: Re: [PATCHv2 05/16] atomics: prepare for atomic64_fetch_add_unless()
Date: Tue, 5 Jun 2018 10:53:58 +0100 [thread overview]
Message-ID: <20180605095357.64zgw3uq3py2pjs4@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20180605092637.GF12258@hirez.programming.kicks-ass.net>
On Tue, Jun 05, 2018 at 11:26:37AM +0200, Peter Zijlstra wrote:
> On Tue, May 29, 2018 at 04:43:35PM +0100, Mark Rutland wrote:
> > /**
> > + * atomic64_add_unless - add unless the number is already a given value
> > + * @v: pointer of type atomic_t
> > + * @a: the amount to add to v...
> > + * @u: ...unless v is equal to u.
> > + *
> > + * Atomically adds @a to @v, so long as @v was not already @u.
> > + * Returns non-zero if @v was not @u, and zero otherwise.
>
> I always get confused by that wording; would something like: "Returns
> true if the addition was done" not be more clear?
Sounds clearer to me; I just stole the wording from the existing
atomic_add_unless().
I guess you'll want similar for the conditional inc/dec ops, e.g.
/**
* atomic_inc_not_zero - increment unless the number is zero
* @v: pointer of type atomic_t
*
* Atomically increments @v by 1, so long as @v is non-zero.
* Returns non-zero if @v was non-zero, and zero otherwise.
*/
> > + */
> > +#ifdef atomic64_fetch_add_unless
> > +static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
>
> Do we want to make that a "bool' return?
I think so -- that's what the instrumented wrappers (and x86) do today
anyhow, and what I ended up using for the generated headers.
I'll spin a prep patch cleaning up the existing fallbacks in
<linux/atomic.h>, along with the comment fixup above, then rework the
additions likewise.
Thanks,
Mark.
next prev parent reply other threads:[~2018-06-05 9:54 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 15:43 [PATCHv2 00/16] atomics: API cleanups Mark Rutland
2018-05-29 15:43 ` [PATCHv2 01/16] atomics/treewide: s/__atomic_add_unless/atomic_fetch_add_unless/ Mark Rutland
2018-06-04 23:24 ` Palmer Dabbelt
2018-05-29 15:43 ` [PATCHv2 02/16] atomics/treewide: remove redundant atomic_inc_not_zero() definitions Mark Rutland
2018-06-04 23:24 ` Palmer Dabbelt
2018-05-29 15:43 ` [PATCHv2 03/16] atomics/treewide: make atomic64_inc_not_zero() optional Mark Rutland
2018-06-04 23:17 ` Palmer Dabbelt
2018-06-05 5:34 ` Mark Rutland
2018-05-29 15:43 ` [PATCHv2 04/16] atomics/treewide: make atomic_fetch_add_unless() optional Mark Rutland
2018-06-04 23:24 ` Palmer Dabbelt
2018-05-29 15:43 ` [PATCHv2 05/16] atomics: prepare for atomic64_fetch_add_unless() Mark Rutland
2018-06-05 9:26 ` Peter Zijlstra
2018-06-05 9:53 ` Mark Rutland [this message]
2018-06-05 10:54 ` Michael Ellerman
2018-06-05 11:08 ` Mark Rutland
2018-06-06 8:57 ` Michael Ellerman
2018-05-29 15:43 ` [PATCHv2 06/16] atomics/generic: define atomic64_fetch_add_unless() Mark Rutland
2018-05-29 15:43 ` [PATCHv2 07/16] atomics/alpha: " Mark Rutland
2018-05-29 15:43 ` [PATCHv2 08/16] atomics/arc: " Mark Rutland
2018-05-29 15:43 ` [PATCHv2 09/16] atomics/arm: " Mark Rutland
2018-05-29 15:43 ` [PATCHv2 10/16] atomics/powerpc: " Mark Rutland
2018-05-29 15:43 ` [PATCHv2 11/16] atomics/riscv: " Mark Rutland
2018-06-04 23:17 ` Palmer Dabbelt
2018-05-29 15:43 ` [PATCHv2 12/16] atomics/treewide: make atomic64_fetch_add_unless() optional Mark Rutland
2018-05-29 15:43 ` [PATCHv2 13/16] atomics/treewide: make test ops optional Mark Rutland
2018-06-04 23:17 ` Palmer Dabbelt
2018-05-29 15:43 ` [PATCHv2 14/16] atomics/treewide: remove atomic_inc_not_zero_hint() Mark Rutland
2018-05-29 15:43 ` [PATCHv2 15/16] atomics/treewide: make unconditional inc/dec ops optional Mark Rutland
2018-06-04 23:17 ` Palmer Dabbelt
2018-05-29 15:43 ` [PATCHv2 16/16] atomics/treewide: make conditional " Mark Rutland
2018-05-30 11:23 ` [PATCHv2 00/16] atomics: API cleanups Mark Rutland
2018-05-30 13:34 ` Mark Rutland
2018-06-05 9:43 ` Peter Zijlstra
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=20180605095357.64zgw3uq3py2pjs4@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=albert@sifive.com \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=boqun.feng@gmail.com \
--cc=ink@jurassic.park.msu.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mattst88@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=palmer@sifive.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=rth@twiddle.net \
--cc=vgupta@synopsys.com \
--cc=will.deacon@arm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).