Commit 03c4cc38 authored by Jesper Dangaard Brouer's avatar Jesper Dangaard Brouer Committed by David S. Miller

bpf: cpumap micro-optimization in cpu_map_enqueue

Discovered that the compiler laid-out asm code in suboptimal way
when studying perf report during benchmarking of cpumap. Help
the compiler by the marking unlikely code paths.
Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 14e83bf8
...@@ -208,7 +208,7 @@ static struct xdp_pkt *convert_to_xdp_pkt(struct xdp_buff *xdp) ...@@ -208,7 +208,7 @@ static struct xdp_pkt *convert_to_xdp_pkt(struct xdp_buff *xdp)
headroom = xdp->data - xdp->data_hard_start; headroom = xdp->data - xdp->data_hard_start;
metasize = xdp->data - xdp->data_meta; metasize = xdp->data - xdp->data_meta;
metasize = metasize > 0 ? metasize : 0; metasize = metasize > 0 ? metasize : 0;
if ((headroom - metasize) < sizeof(*xdp_pkt)) if (unlikely((headroom - metasize) < sizeof(*xdp_pkt)))
return NULL; return NULL;
/* Store info in top of packet */ /* Store info in top of packet */
...@@ -656,7 +656,7 @@ int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp, ...@@ -656,7 +656,7 @@ int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp,
struct xdp_pkt *xdp_pkt; struct xdp_pkt *xdp_pkt;
xdp_pkt = convert_to_xdp_pkt(xdp); xdp_pkt = convert_to_xdp_pkt(xdp);
if (!xdp_pkt) if (unlikely(!xdp_pkt))
return -EOVERFLOW; return -EOVERFLOW;
/* Info needed when constructing SKB on remote CPU */ /* Info needed when constructing SKB on remote CPU */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment