提交 e1302542 编写于 作者: J Jesper Dangaard Brouer 提交者: Alexei Starovoitov

xdp: unlikely instrumentation for xdp map redirect

Notice the compiler generated ASM code layout was suboptimal.  It
assumed map enqueue errors as the likely case, which is shouldn't.
It assumed that xdp_do_flush_map() was a likely case, due to maps
changing between packets, which should be very unlikely.
Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 a9c676bc
...@@ -3187,7 +3187,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd, ...@@ -3187,7 +3187,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
struct bpf_dtab_netdev *dst = fwd; struct bpf_dtab_netdev *dst = fwd;
err = dev_map_enqueue(dst, xdp, dev_rx); err = dev_map_enqueue(dst, xdp, dev_rx);
if (err) if (unlikely(err))
return err; return err;
__dev_map_insert_ctx(map, index); __dev_map_insert_ctx(map, index);
break; break;
...@@ -3196,7 +3196,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd, ...@@ -3196,7 +3196,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
struct bpf_cpu_map_entry *rcpu = fwd; struct bpf_cpu_map_entry *rcpu = fwd;
err = cpu_map_enqueue(rcpu, xdp, dev_rx); err = cpu_map_enqueue(rcpu, xdp, dev_rx);
if (err) if (unlikely(err))
return err; return err;
__cpu_map_insert_ctx(map, index); __cpu_map_insert_ctx(map, index);
break; break;
...@@ -3284,7 +3284,7 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, ...@@ -3284,7 +3284,7 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
err = -EINVAL; err = -EINVAL;
goto err; goto err;
} }
if (ri->map_to_flush && ri->map_to_flush != map) if (ri->map_to_flush && unlikely(ri->map_to_flush != map))
xdp_do_flush_map(); xdp_do_flush_map();
err = __bpf_tx_xdp_map(dev, fwd, map, xdp, index); err = __bpf_tx_xdp_map(dev, fwd, map, xdp, index);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册