[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200218144037.GC14946@hirez.programming.kicks-ass.net>
Date: Tue, 18 Feb 2020 15:40:37 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Carter Li 李通洲 <carter.li@...tek.com>,
Pavel Begunkov <asml.silence@...il.com>,
io-uring <io-uring@...r.kernel.org>,
Oleg Nesterov <oleg@...hat.com>,
Mark Rutland <mark.rutland@....com>,
linux-kernel@...r.kernel.org, Will Deacon <will@...nel.org>
Subject: Re: [PATCH] asm-generic/atomic: Add try_cmpxchg() fallbacks
On Tue, Feb 18, 2020 at 03:27:00PM +0100, Peter Zijlstra wrote:
> diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh
> index b6c6f5d306a7..3c9be8d550e0 100755
> --- a/scripts/atomic/gen-atomic-fallback.sh
> +++ b/scripts/atomic/gen-atomic-fallback.sh
> @@ -140,6 +140,32 @@ cat <<EOF
> EOF
> }
>
> +gen_try_cmpxchg_fallback()
> +{
> + local order="$1"; shift;
> +
> +cat <<EOF
> +#ifndef try_cmpxchg${order}
> +#define try_cmpxchg${order}(_ptr, _oldp, _new) \\
> +({ \\
> + typeof(*ptr) ___r, ___o = *(_oldp); \\
*(_ptr)
> + ___r = cmpxchg${order}((_ptr), ___o, (_new)); \\
> + if (unlikely(___r != ___o)) \\
> + *(_old) = ___r; \\
*(_oldp)
> + likely(___r == ___o); \\
> +})
> +#endif /* try_cmpxchg${order} */
And it actually builds, as tested on an ARM build.
Powered by blists - more mailing lists