[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151111172659.GA86334@ast-mbp.thefacebook.com>
Date: Wed, 11 Nov 2015 09:27:00 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Will Deacon <will.deacon@....com>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Peter Zijlstra <peterz@...radead.org>,
Arnd Bergmann <arnd@...db.de>,
"Shi, Yang" <yang.shi@...aro.org>, linaro-kernel@...ts.linaro.org,
Eric Dumazet <eric.dumazet@...il.com>,
Z Lim <zlim.lnx@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>,
Xi Wang <xi.wang@...il.com>,
Catalin Marinas <catalin.marinas@....com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, yhs@...mgrid.com,
bblanco@...mgrid.com
Subject: Re: [PATCH 2/2] arm64: bpf: add BPF XADD instruction
On Wed, Nov 11, 2015 at 04:23:41PM +0000, Will Deacon wrote:
>
> If we're going to document it, a bug tracker might be a good place to
> start. The behaviour, as it stands, is broken wrt the definition of the
> __sync primitives. That is, there is no way to build __sync_fetch_and_add
> out of BPF_XADD without changing its semantics.
BPF_XADD == atomic_add() in kernel. period.
we are not going to deprecate it or introduce something else.
Semantics of __sync* or atomic in C standard and/or gcc/llvm has
nothing to do with this.
arm64 JIT needs to JIT bpf_xadd insn equivalent to the code
of atomic_add() which is 'stadd' in armv8.1.
The cpu check can be done by jit and for older cpus just fall back
to interpreter. trivial.
> We could fix this by either:
>
> (1) Defining BPF_XADD to match __sync_fetch_and_add (including memory
> barriers).
nope.
> (2) Introducing some new BPF_ atomics, that map to something like the
> C11 __atomic builtins and deprecating BPF_XADD in favour of these.
nope.
> (3) Introducing new source-language intrinsics to match what BPF can do
> (unlikely to be popular).
llvm's __sync intrinsic is used temporarily until we have time to do
new intrinsic in llvm that matches kernel's atomic_add() properly.
It will be done similar to llvm-bpf load_byte/word intrinsics.
Note that we've been hiding it under lock_xadd() wrapper, like here:
https://github.com/iovisor/bcc/blob/master/examples/networking/tunnel_monitor/monitor.c#L130
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists