bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] Optimize bpf_redirect_map()/xdp_do_redirect()
@ 2021-02-19 14:59 Björn Töpel
  2021-02-19 14:59 ` [PATCH bpf-next 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP Björn Töpel
  2021-02-19 14:59 ` [PATCH bpf-next 2/2] bpf, xdp: restructure redirect actions Björn Töpel
  0 siblings, 2 replies; 9+ messages in thread
From: Björn Töpel @ 2021-02-19 14:59 UTC (permalink / raw)
  To: ast, daniel, netdev, bpf
  Cc: Björn Töpel, bjorn.topel, maciej.fijalkowski, hawk,
	toke, magnus.karlsson, john.fastabend, kuba, davem

Hi XDP-folks,

This two patch series contain two optimizations for the
bpf_redirect_map() helper and the xdp_do_redirect() function.

The bpf_redirect_map() optimization is about avoiding the map lookup
dispatching. Instead of having a switch-statement and selecting the
correct lookup function, we let the verifier patch the
bpf_redirect_map() call to a specific lookup function. This way the
run-time lookup is avoided.

The xdp_do_redirect() patch restructures the code, so that the map
pointer indirection can be avoided.

Performance-wise I got 3% improvement for XSKMAP
(sample:xdpsock/rx-drop), and 4% (sample:xdp_redirect_map) on my
machine.

More details in each commit. Changes since the RFC is outlined in each
commit.


Cheers,
Björn


Björn Töpel (2):
  bpf, xdp: per-map bpf_redirect_map functions for XDP
  bpf, xdp: restructure redirect actions

 include/linux/bpf.h        |  20 ++--
 include/linux/filter.h     |  13 ++-
 include/net/xdp_sock.h     |   6 +-
 include/trace/events/xdp.h |  66 ++++++-----
 kernel/bpf/cpumap.c        |   3 +-
 kernel/bpf/devmap.c        |   5 +-
 kernel/bpf/verifier.c      |  28 +++--
 net/core/filter.c          | 219 ++++++++++++++++++-------------------
 net/xdp/xskmap.c           |   1 -
 9 files changed, 192 insertions(+), 169 deletions(-)


base-commit: 7b1e385c9a488de9291eaaa412146d3972e9dec5
-- 
2.27.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-19 18:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 14:59 [PATCH bpf-next 0/2] Optimize bpf_redirect_map()/xdp_do_redirect() Björn Töpel
2021-02-19 14:59 ` [PATCH bpf-next 1/2] bpf, xdp: per-map bpf_redirect_map functions for XDP Björn Töpel
2021-02-19 17:05   ` Toke Høiland-Jørgensen
2021-02-19 17:47     ` Björn Töpel
2021-02-19 17:08   ` kernel test robot
2021-02-19 18:13   ` kernel test robot
2021-02-19 14:59 ` [PATCH bpf-next 2/2] bpf, xdp: restructure redirect actions Björn Töpel
2021-02-19 17:10   ` Toke Høiland-Jørgensen
2021-02-19 17:49     ` Björn Töpel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).