From: Magnus Karlsson <magnus.karlsson@intel.com>
To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@kernel.org,
daniel@iogearbox.net, netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, bruce.richardson@intel.com,
ciara.loftus@intel.com, ilias.apalodimas@linaro.org,
xiaolong.ye@intel.com, ferruh.yigit@intel.com,
qi.z.zhang@intel.com, georgmueller@gmx.net
Subject: [PATCH bpf 1/2] libbpf: remove likely/unlikely in xsk.h
Date: Tue, 9 Apr 2019 08:44:12 +0200 [thread overview]
Message-ID: <1554792253-27081-2-git-send-email-magnus.karlsson@intel.com> (raw)
In-Reply-To: <1554792253-27081-1-git-send-email-magnus.karlsson@intel.com>
This patch removes the use of likely and unlikely in xsk.h since they
create a dependency on Linux headers as reported by several
users. There have also been reports that the use of these decreases
performance as the compiler puts the code on two different cache lines
instead of on a single one. All in all, I think we are better off
without them.
Fixes: 1cad07884239 ("libbpf: add support for using AF_XDP sockets")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
tools/lib/bpf/xsk.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
index a497f00..3638147 100644
--- a/tools/lib/bpf/xsk.h
+++ b/tools/lib/bpf/xsk.h
@@ -105,7 +105,7 @@ static inline __u32 xsk_cons_nb_avail(struct xsk_ring_cons *r, __u32 nb)
static inline size_t xsk_ring_prod__reserve(struct xsk_ring_prod *prod,
size_t nb, __u32 *idx)
{
- if (unlikely(xsk_prod_nb_free(prod, nb) < nb))
+ if (xsk_prod_nb_free(prod, nb) < nb)
return 0;
*idx = prod->cached_prod;
@@ -129,7 +129,7 @@ static inline size_t xsk_ring_cons__peek(struct xsk_ring_cons *cons,
{
size_t entries = xsk_cons_nb_avail(cons, nb);
- if (likely(entries > 0)) {
+ if (entries > 0) {
/* Make sure we do not speculatively read the data before
* we have received the packet buffers from the ring.
*/
--
2.7.4
next prev parent reply other threads:[~2019-04-09 6:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 6:44 [PATCH bpf 0/2] libbpf: remove two dependencies on Linux kernel headers and improve performance as a bonus Magnus Karlsson
2019-04-09 6:44 ` Magnus Karlsson [this message]
2019-04-09 6:44 ` [PATCH bpf 2/2] libbpf: remove dependency on barrier.h in xsk.h Magnus Karlsson
2019-04-09 9:10 ` Daniel Borkmann
2019-04-09 11:29 ` Magnus Karlsson
2019-04-09 22:28 ` Georg Müller
2019-04-09 22:46 ` Daniel Borkmann
2019-09-04 5:32 ` Yauheni Kaliuta
2019-09-04 6:39 ` Magnus Karlsson
2019-09-04 6:56 ` Yauheni Kaliuta
2019-09-04 10:25 ` Magnus Karlsson
2019-09-04 12:19 ` Yauheni Kaliuta
2019-09-04 12:21 ` Magnus Karlsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1554792253-27081-2-git-send-email-magnus.karlsson@intel.com \
--to=magnus.karlsson@intel.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=bruce.richardson@intel.com \
--cc=ciara.loftus@intel.com \
--cc=daniel@iogearbox.net \
--cc=ferruh.yigit@intel.com \
--cc=georgmueller@gmx.net \
--cc=ilias.apalodimas@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=qi.z.zhang@intel.com \
--cc=xiaolong.ye@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).