]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
libbpf: fix XDP socket ring buffer memory ordering
authorMagnus Karlsson <magnus.karlsson@intel.com>
Tue, 16 Apr 2019 12:58:09 +0000 (14:58 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 17 Apr 2019 03:13:10 +0000 (20:13 -0700)
commitd5e63fdd443378531fd1a67a15a720a799635d93
tree660aac2b1620cc27e326a15655c94732cfcad445
parentf63666de2ba9c1c3ac0ec57fc5d3032514ec80f1
libbpf: fix XDP socket ring buffer memory ordering

The ring buffer code of XDP sockets is missing a memory barrier on the
consumer side between the load of the data and the write that signals
that it is ok for the producer to put new data into the buffer. On
architectures that does not guarantee that stores are not reordered
with older loads, the producer might put data into the ring before the
consumer had the chance to read it. As IA does guarantee this
ordering, it would only need a compiler barrier here, but there are no
primitives in barrier.h for this specific case (hinder writes to be ordered
before older reads) so I had to add a smp_mb() here which will
translate into a run-time synch operation on IA.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/xsk.h