[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1555419492-16906-1-git-send-email-magnus.karlsson@intel.com>
Date: Tue, 16 Apr 2019 14:58:07 +0200
From: Magnus Karlsson <magnus.karlsson@...el.com>
To: magnus.karlsson@...el.com, bjorn.topel@...el.com, ast@...nel.org,
daniel@...earbox.net, netdev@...r.kernel.org
Cc: bpf@...r.kernel.org, bruce.richardson@...el.com,
ciara.loftus@...el.com, ilias.apalodimas@...aro.org,
xiaolong.ye@...el.com, ferruh.yigit@...el.com,
qi.z.zhang@...el.com, georgmueller@....net
Subject: [PATCH bpf v3 0/5] libbpf: remove two dependencies on Linux
This patch set fixes one bug and removes two dependencies on Linux
kernel headers from the XDP socket code in libbpf. A number of people
have pointed out that these two dependencies make it hard to build the
XDP socket part of libbpf without any kernel header dependencies. The
two removed dependecies are:
* Remove the usage of likely and unlikely (compiler.h) in xsk.h. It
has been reported that the use of these actually decreases the
performance of the ring access code due to an increase in
instruction cache misses, so let us just remove these.
* Remove the dependency on barrier.h as it brings in a lot of kernel
headers. As the XDP socket code only uses two simple functions from
it, we can reimplement these. As a bonus, the new implementation is
faster as it uses the same barrier primitives as the kernel does
when the same code is compiled there. Without this patch, the user
land code uses lfence and sfence on x86, which are unnecessarily
harsh/thorough.
In the process of removing these dependencies a missing barrier
function for at least PPC64 was discovered. For a full explanation on
the missing barrier, please refer to patch 1. So the patch set now
starts with two patches fixing this. I have also added a patch at the
end removing this full memory barrier for x86 only, as it is not
needed there.
Structure of the patch set:
Patch 1-2: Adds the missing barrier function in kernel and user space.
Patch 3-4: Removes the dependencies
Patch 5: Optimizes the added barrier from patch 2 so that it does not
do unnecessary work on x86.
v2 -> v3:
* Added missing memory barrier in ring code
* Added an explanation on the three barriers we use in the code
* Moved barrier functions from xsk.h to libbpf_util.h
* Added comment on why we have these functions in libbpf_util.h
* Added a new barrier function in user space that makes it possible to
remove the full memory barrier on x86.
v1 -> v2:
* Added comment about validity of ARM 32-bit barriers.
Only armv7 and above.
/Magnus
Magnus Karlsson (5):
xsk: fix XDP socket ring buffer memory ordering
libbpf: fix XDP socket ring buffer memory ordering
libbpf: remove likely/unlikely in xsk.h
libbpf: remove dependency on barrier.h in xsk.h
libbpf: optimize barrier for XDP socket rings
net/xdp/xsk_queue.h | 56 +++++++++++++++++++++++++++++++++++++++++----
tools/lib/bpf/libbpf_util.h | 30 ++++++++++++++++++++++++
tools/lib/bpf/xsk.h | 22 +++++++++++++-----
3 files changed, 98 insertions(+), 10 deletions(-)
--
2.7.4
Powered by blists - more mailing lists