Skip to content

Commit

Permalink
libbpf: remove likely/unlikely in xsk.h
Browse files Browse the repository at this point in the history
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: 1cad078 ("libbpf: add support for using AF_XDP sockets")
Signed-off-by: Magnus Karlsson <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
magnus-karlsson authored and Alexei Starovoitov committed Apr 17, 2019
1 parent d5e63fd commit a06d729
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/lib/bpf/xsk.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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;
Expand All @@ -133,7 +133,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.
*/
Expand Down

0 comments on commit a06d729

Please sign in to comment.