diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2017-11-01 07:44:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-02 03:13:14 -0400 |
commit | 03c4cc385faaa46e5877f499c6b997fef792f8d3 (patch) | |
tree | 0e384397a2bb6b6a0483b151622edbf7aaa8b99a /kernel/bpf | |
parent | 14e83bf82961aeebef41976139c61ab82c84a238 (diff) |
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: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf')
-rw-r--r-- | kernel/bpf/cpumap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index 86e29cbf7827..ce5b669003b2 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c | |||
@@ -208,7 +208,7 @@ static struct xdp_pkt *convert_to_xdp_pkt(struct xdp_buff *xdp) | |||
208 | headroom = xdp->data - xdp->data_hard_start; | 208 | headroom = xdp->data - xdp->data_hard_start; |
209 | metasize = xdp->data - xdp->data_meta; | 209 | metasize = xdp->data - xdp->data_meta; |
210 | metasize = metasize > 0 ? metasize : 0; | 210 | metasize = metasize > 0 ? metasize : 0; |
211 | if ((headroom - metasize) < sizeof(*xdp_pkt)) | 211 | if (unlikely((headroom - metasize) < sizeof(*xdp_pkt))) |
212 | return NULL; | 212 | return NULL; |
213 | 213 | ||
214 | /* Store info in top of packet */ | 214 | /* 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 | struct xdp_pkt *xdp_pkt; | 656 | struct xdp_pkt *xdp_pkt; |
657 | 657 | ||
658 | xdp_pkt = convert_to_xdp_pkt(xdp); | 658 | xdp_pkt = convert_to_xdp_pkt(xdp); |
659 | if (!xdp_pkt) | 659 | if (unlikely(!xdp_pkt)) |
660 | return -EOVERFLOW; | 660 | return -EOVERFLOW; |
661 | 661 | ||
662 | /* Info needed when constructing SKB on remote CPU */ | 662 | /* Info needed when constructing SKB on remote CPU */ |