History

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.

Björn Töpel committed 6 years ago

Commit 332f22a1 parent cdfafe92 files · +3 −25Browse files

Unified · Split

2 files
  1. include/linux/filter.h +0 −1
  2. net/core/filter.c +3 −24
include/linux/filter.h+0−1
@@ -592,7 +592,6 @@ struct bpf_redirect_info { · 591 unmodified lines
592592 u32 tgt_index;
593593 void *tgt_value;
594594 struct bpf_map *map;
595− struct bpf_map *map_to_flush;
596595 u32 kern_flags;
597596 };
598597
net/core/filter.c+3−24
@@ -3547,26 +3547,9 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd, · 3546 unmodified lines
35473547
35483548 void xdp_do_flush_map(void)
35493549 {
3550− struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
3551− struct bpf_map *map = ri->map_to_flush;
3552−
3553− ri->map_to_flush = NULL;
3554− if (map) {
3555− switch (map->map_type) {
3556− case BPF_MAP_TYPE_DEVMAP:
3557− case BPF_MAP_TYPE_DEVMAP_HASH:
3558− __dev_map_flush();
3559− break;
3560− case BPF_MAP_TYPE_CPUMAP:
3561− __cpu_map_flush();
3562− break;
3563− case BPF_MAP_TYPE_XSKMAP:
3564− __xsk_map_flush();
3565− break;
3566− default:
3567− break;
3568− }
3569− }
3550+ __dev_map_flush();
3551+ __cpu_map_flush();
3552+ __xsk_map_flush();
35703553 }
35713554 EXPORT_SYMBOL_GPL(xdp_do_flush_map);
35723555
@@ -3615,14 +3598,10 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp, · 42 unmodified lines
36153598 ri->tgt_value = NULL;
36163599 WRITE_ONCE(ri->map, NULL);
36173600
3618− if (ri->map_to_flush && unlikely(ri->map_to_flush != map))
3619− xdp_do_flush_map();
3620−
36213601 err = __bpf_tx_xdp_map(dev, fwd, map, xdp);
36223602 if (unlikely(err))
36233603 goto err;
36243604
3625− ri->map_to_flush = map;
36263605 _trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index);
36273606 return 0;
36283607 err:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t