From: Alexei Starovoitov <ast@fb.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Fengguang Wu <fengguang.wu@intel.com>, <netdev@vger.kernel.org>,
<kernel-team@fb.com>
Subject: [PATCH net-next 0/6] bpf: inline bpf_map_lookup_elem()
Date: Wed, 15 Mar 2017 18:26:38 -0700 [thread overview]
Message-ID: <1489627604-2288703-1-git-send-email-ast@fb.com> (raw)
bpf_map_lookup_elem() is one of the most frequently used helper functions.
Improve JITed program performance by inlining this helper.
bpf_map_type before after
hash 58M 74M
array 174M 280M
The values are number of lookups per second in ideal conditions
measured by micro-benchmark in patch 6.
The 'perf report' for HASH map type:
before:
54.23% map_perf_test [kernel.kallsyms] [k] __htab_map_lookup_elem
14.24% map_perf_test [kernel.kallsyms] [k] lookup_elem_raw
8.84% map_perf_test [kernel.kallsyms] [k] htab_map_lookup_elem
5.93% map_perf_test [kernel.kallsyms] [k] bpf_map_lookup_elem
2.30% map_perf_test [kernel.kallsyms] [k] bpf_prog_da4fc6a3f41761a2
1.49% map_perf_test [kernel.kallsyms] [k] kprobe_ftrace_handler
after:
60.03% map_perf_test [kernel.kallsyms] [k] __htab_map_lookup_elem
18.07% map_perf_test [kernel.kallsyms] [k] lookup_elem_raw
2.91% map_perf_test [kernel.kallsyms] [k] bpf_prog_da4fc6a3f41761a2
1.94% map_perf_test [kernel.kallsyms] [k] _einittext
1.90% map_perf_test [kernel.kallsyms] [k] __audit_syscall_exit
1.72% map_perf_test [kernel.kallsyms] [k] kprobe_ftrace_handler
so the cost of htab_map_lookup_elem() and bpf_map_lookup_elem()
is gone after inlining.
'per-cpu' and 'lru' map types can be optimized similarly in the future.
Note the sparse will complain that bpf is addictive ;)
kernel/bpf/hashtab.c:438:19: sparse: subtraction of functions? Share your drugs
kernel/bpf/verifier.c:3342:38: sparse: subtraction of functions? Share your drugs
it's not a new warning, just in new places.
Alexei Starovoitov (6):
bpf: move fixup_bpf_calls() function
bpf: refactor fixup_bpf_calls()
bpf: adjust insn_aux_data when patching insns
bpf: add helper inlining infra and optimize map_array lookup
bpf: inline htab_map_lookup_elem()
samples/bpf: add map_lookup microbenchmark
include/linux/bpf.h | 1 +
include/linux/bpf_verifier.h | 5 +-
include/linux/filter.h | 10 +++
kernel/bpf/arraymap.c | 29 +++++++++
kernel/bpf/hashtab.c | 31 +++++++++-
kernel/bpf/syscall.c | 56 -----------------
kernel/bpf/verifier.c | 129 ++++++++++++++++++++++++++++++++++++---
samples/bpf/map_perf_test_kern.c | 33 ++++++++++
samples/bpf/map_perf_test_user.c | 32 ++++++++++
9 files changed, 261 insertions(+), 65 deletions(-)
--
2.8.0
next reply other threads:[~2017-03-16 1:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 1:26 Alexei Starovoitov [this message]
2017-03-16 1:26 ` [PATCH net-next 1/6] bpf: move fixup_bpf_calls() function Alexei Starovoitov
2017-03-16 1:26 ` [PATCH net-next 2/6] bpf: refactor fixup_bpf_calls() Alexei Starovoitov
2017-03-16 1:26 ` [PATCH net-next 3/6] bpf: adjust insn_aux_data when patching insns Alexei Starovoitov
2017-03-16 1:26 ` [PATCH net-next 4/6] bpf: add helper inlining infra and optimize map_array lookup Alexei Starovoitov
2017-03-16 1:26 ` [PATCH net-next 5/6] bpf: inline htab_map_lookup_elem() Alexei Starovoitov
2017-03-16 1:26 ` [PATCH net-next 6/6] samples/bpf: add map_lookup microbenchmark Alexei Starovoitov
2017-03-17 3:44 ` [PATCH net-next 0/6] bpf: inline bpf_map_lookup_elem() David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489627604-2288703-1-git-send-email-ast@fb.com \
--to=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=fengguang.wu@intel.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).