net: Optimize xdp_do_flush() with bpf_net_context infos.
Every NIC driver utilizing XDP should invoke xdp_do_flush() after processing all packages. With the introduction of the bpf_net_context logic the flush lists (for dev, CPU-map and xsk) are lazy initialized only if used. However xdp_do_flush() tries to flush all three of them so all three lists are always initialized and the likely empty lists are "iterated". Without the usage of XDP but with CONFIG_DEBUG_NET the lists are also initialized due to xdp_do_check_flushed(). Jakub suggest to utilize the hints in bpf_net_context and avoid invoking the flush function. This will also avoiding initializing the lists which are otherwise unused. Introduce bpf_net_ctx_get_all_used_flush_lists() to return the individual list if not-empty. Use the logic in xdp_do_flush() and xdp_do_check_flushed(). Remove the not needed .*_check_flush(). Suggested-by:Jakub Kicinski <kuba@kernel.org> Signed-off-by:
Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by:
Jakub Kicinski <kuba@kernel.org> Signed-off-by:
Paolo Abeni <pabeni@redhat.com>
Showing
- include/linux/bpf.h 4 additions, 6 deletionsinclude/linux/bpf.h
- include/linux/filter.h 27 additions, 0 deletionsinclude/linux/filter.h
- include/net/xdp_sock.h 2 additions, 12 deletionsinclude/net/xdp_sock.h
- kernel/bpf/cpumap.c 1 addition, 12 deletionskernel/bpf/cpumap.c
- kernel/bpf/devmap.c 1 addition, 12 deletionskernel/bpf/devmap.c
- net/core/filter.c 25 additions, 8 deletionsnet/core/filter.c
- net/xdp/xsk.c 1 addition, 12 deletionsnet/xdp/xsk.c
Please register or sign in to comment