Commit 332f22a6 authored by Björn Töpel's avatar Björn Töpel Committed by Alexei Starovoitov

xdp: Remove map_to_flush and map swap detection

Now that all XDP maps that can be used with bpf_redirect_map() tracks
entries to be flushed in a global fashion, there is not need to track
that the map has changed and flush from xdp_do_generic_map()
anymore. All entries will be flushed in xdp_do_flush_map().

This means that the map_to_flush can be removed, and the corresponding
checks. Moving the flush logic to one place, xdp_do_flush_map(), give
a bulking behavior and performance boost.
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20191219061006.21980-8-bjorn.topel@gmail.com
parent cdfafe98
...@@ -592,7 +592,6 @@ struct bpf_redirect_info { ...@@ -592,7 +592,6 @@ struct bpf_redirect_info {
u32 tgt_index; u32 tgt_index;
void *tgt_value; void *tgt_value;
struct bpf_map *map; struct bpf_map *map;
struct bpf_map *map_to_flush;
u32 kern_flags; u32 kern_flags;
}; };
......
...@@ -3547,26 +3547,9 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd, ...@@ -3547,26 +3547,9 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
void xdp_do_flush_map(void) void xdp_do_flush_map(void)
{ {
struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info); __dev_map_flush();
struct bpf_map *map = ri->map_to_flush; __cpu_map_flush();
__xsk_map_flush();
ri->map_to_flush = NULL;
if (map) {
switch (map->map_type) {
case BPF_MAP_TYPE_DEVMAP:
case BPF_MAP_TYPE_DEVMAP_HASH:
__dev_map_flush();
break;
case BPF_MAP_TYPE_CPUMAP:
__cpu_map_flush();
break;
case BPF_MAP_TYPE_XSKMAP:
__xsk_map_flush();
break;
default:
break;
}
}
} }
EXPORT_SYMBOL_GPL(xdp_do_flush_map); EXPORT_SYMBOL_GPL(xdp_do_flush_map);
...@@ -3615,14 +3598,10 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, ...@@ -3615,14 +3598,10 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
ri->tgt_value = NULL; ri->tgt_value = NULL;
WRITE_ONCE(ri->map, NULL); WRITE_ONCE(ri->map, NULL);
if (ri->map_to_flush && unlikely(ri->map_to_flush != map))
xdp_do_flush_map();
err = __bpf_tx_xdp_map(dev, fwd, map, xdp); err = __bpf_tx_xdp_map(dev, fwd, map, xdp);
if (unlikely(err)) if (unlikely(err))
goto err; goto err;
ri->map_to_flush = map;
_trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index); _trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index);
return 0; return 0;
err: err:
......
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