lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180605095357.64zgw3uq3py2pjs4@lakrids.cambridge.arm.com>
Date:   Tue, 5 Jun 2018 10:53:58 +0100
From:   Mark Rutland <mark.rutland@....com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     linux-kernel@...r.kernel.org, Boqun Feng <boqun.feng@...il.com>,
        Will Deacon <will.deacon@....com>,
        Arnd Bergmann <arnd@...db.de>,
        Richard Henderson <rth@...ddle.net>,
        Ivan Kokshaysky <ink@...assic.park.msu.ru>,
        Matt Turner <mattst88@...il.com>,
        Vineet Gupta <vgupta@...opsys.com>,
        Russell King <linux@...linux.org.uk>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Palmer Dabbelt <palmer@...ive.com>,
        Albert Ou <albert@...ive.com>
Subject: Re: [PATCHv2 05/16] atomics: prepare for atomic64_fetch_add_unless()

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ