[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1892721.uUY0g5DXJQ@wuerfel>
Date: Wed, 17 Aug 2011 21:20:36 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Richard Kuo <rkuo@...eaurora.org>
Cc: linux-kernel@...r.kernel.org, linux-hexagon@...r.kernel.org
Subject: Re: [patch 04/36] Hexagon: Add atomic ops support
On Wednesday 17 August 2011 11:35:01 Richard Kuo wrote:
> +/**
> + * atomic_add_unless - add unless the number is a given value
> + * @v: pointer to value
> + * @a: amount to add
> + * @u: unless value is equal to u
> + *
> + * This is actually in the asm-generic version; should revisit this
> + * entire file...
> + */
> +static inline int __atomic_add_unless(atomic_t *v, int a, int u)
> +{
> + int c, old;
> +
> + c = atomic_read(v);
> + for (;;) {
> + if (unlikely(c == u))
> + break;
> + old = atomic_cmpxchg((v), c, c + a);
> + if (likely(old == c))
> + break;
> + c = old;
> + }
> + return c != u;
> +}
It's probably worth doing this in a single inline assembly instead
of two nested loops (the second one being inside of atomic_cmpxchg.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists