Andrey Ignatov
0640c77c46
bpf: Avoid retpoline for bpf_for_each_map_elem
...
Similarly to 09772d92cd5a ("bpf: avoid retpoline for
lookup/update/delete calls on maps") and 84430d4232c3 ("bpf, verifier:
avoid retpoline for map push/pop/peek operation") avoid indirect call
while calling bpf_for_each_map_elem.
Before (a program fragment):
; if (rules_map) {
142: (15) if r4 == 0x0 goto pc+8
143: (bf) r3 = r10
; bpf_for_each_map_elem(rules_map, process_each_rule, &ctx, 0);
144: (07) r3 += -24
145: (bf) r1 = r4
146: (18) r2 = subprog[+5]
148: (b7) r4 = 0
149: (85) call bpf_for_each_map_elem#143680 <-- indirect call via
helper
After (same program fragment):
; if (rules_map) {
142: (15) if r4 == 0x0 goto pc+8
143: (bf) r3 = r10
; bpf_for_each_map_elem(rules_map, process_each_rule, &ctx, 0);
144: (07) r3 += -24
145: (bf) r1 = r4
146: (18) r2 = subprog[+5]
148: (b7) r4 = 0
149: (85) call bpf_for_each_array_elem#170336 <-- direct call
On a benchmark that calls bpf_for_each_map_elem() once and does many
other things (mostly checking fields in skb) with CONFIG_RETPOLINE=y it
makes program faster.
Before:
============================================================================
Benchmark.cpp time/iter iters/s
============================================================================
IngressMatchByRemoteEndpoint 80.78ns 12.38M
IngressMatchByRemoteIP 80.66ns 12.40M
IngressMatchByRemotePort 80.87ns 12.37M
After:
============================================================================
Benchmark.cpp time/iter iters/s
============================================================================
IngressMatchByRemoteEndpoint 73.49ns 13.61M
IngressMatchByRemoteIP 71.48ns 13.99M
IngressMatchByRemotePort 70.39ns 14.21M
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211006001838.75607-1-rdna@fb.com
2021-10-05 19:22:33 -07:00
..
2021-09-13 15:36:47 -07:00
2021-09-28 16:27:18 -07:00
2021-05-24 21:13:05 -07:00
2021-08-17 00:45:07 +02:00
2021-02-26 11:51:48 -08:00
2021-02-10 15:54:26 -08:00
2020-04-06 21:54:10 +02:00
2021-06-17 11:54:56 -07:00
2020-01-09 08:46:18 -08:00
2021-09-14 11:09:50 -07:00
2021-08-25 10:37:05 -07:00
2021-10-05 17:07:42 -07:00
2021-08-23 17:50:24 -07:00
2021-10-05 17:07:41 -07:00
2021-07-07 20:01:45 -07:00
2021-08-09 23:25:14 +02:00
2021-09-02 14:49:23 +02:00
2021-09-02 14:49:23 +02:00
2020-03-13 12:49:52 -07:00
2021-09-28 16:27:18 -07:00
2021-09-28 16:27:18 -07:00
2021-06-22 14:57:43 +02:00
2021-07-15 18:17:49 -07:00
2021-07-27 15:59:29 -07:00
2021-06-24 19:41:15 +02:00
2021-02-26 11:51:47 -08:00
2021-07-15 22:31:10 +02:00
2020-08-28 15:41:30 +02:00
2020-08-21 14:01:39 -07:00
2020-08-01 20:38:28 -07:00
2020-02-17 16:53:49 +01:00
2020-10-06 00:04:11 +02:00
2020-10-06 00:04:11 +02:00
2020-07-25 20:16:32 -07:00
2020-12-02 18:32:46 -08:00
2021-05-24 21:13:05 -07:00
2021-06-28 15:57:46 +02:00
2021-09-10 22:24:23 +02:00
2021-08-20 00:09:49 +02:00
2020-11-10 15:25:53 -08:00
2021-08-25 10:37:05 -07:00
2021-06-01 13:34:15 +02:00
2021-09-13 10:53:50 -07:00
2021-10-05 19:22:33 -07:00