From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Menglong Dong <menglong8.dong@gmail.com>
Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
hca@linux.ibm.com, revest@chromium.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 0/4] fprobe: use rhashtable for fprobe_ip_table
Date: Tue, 19 Aug 2025 10:48:50 +0900 [thread overview]
Message-ID: <20250819104850.1a903746f2eca854490e770b@kernel.org> (raw)
In-Reply-To: <20250817024607.296117-1-dongml2@chinatelecom.cn>
On Sun, 17 Aug 2025 10:46:01 +0800
Menglong Dong <menglong8.dong@gmail.com> wrote:
> For now, the budget of the hash table that is used for fprobe_ip_table is
> fixed, which is 256, and can cause huge overhead when the hooked functions
> is a huge quantity.
>
> In this series, we use rhltable for fprobe_ip_table to reduce the
> overhead.
>
> Meanwhile, we also add the benchmark testcase "kprobe-multi-all" and, which
> will hook all the kernel functions during the testing. Before this series,
> the performance is:
> usermode-count : 889.269 ± 0.053M/s
> kernel-count : 437.149 ± 0.501M/s
> syscall-count : 31.618 ± 0.725M/s
> fentry : 135.591 ± 0.129M/s
> fexit : 68.127 ± 0.062M/s
> fmodret : 71.764 ± 0.098M/s
> rawtp : 198.375 ± 0.190M/s
> tp : 79.770 ± 0.064M/s
> kprobe : 54.590 ± 0.021M/s
> kprobe-multi : 57.940 ± 0.044M/s
> kprobe-multi-all: 12.151 ± 0.020M/s
> kretprobe : 21.945 ± 0.163M/s
> kretprobe-multi: 28.199 ± 0.018M/s
> kretprobe-multi-all: 9.667 ± 0.008M/s
>
> With this series, the performance is:
> usermode-count : 888.863 ± 0.378M/s
> kernel-count : 429.339 ± 0.136M/s
> syscall-count : 31.215 ± 0.019M/s
> fentry : 135.604 ± 0.118M/s
> fexit : 68.470 ± 0.074M/s
> fmodret : 70.957 ± 0.016M/s
> rawtp : 202.650 ± 0.304M/s
> tp : 80.428 ± 0.053M/s
> kprobe : 55.915 ± 0.074M/s
> kprobe-multi : 54.015 ± 0.039M/s
> kprobe-multi-all: 46.381 ± 0.024M/s
> kretprobe : 22.234 ± 0.050M/s
> kretprobe-multi: 27.946 ± 0.016M/s
> kretprobe-multi-all: 24.439 ± 0.016M/s
>
> The benchmark of "kprobe-multi-all" increase from 12.151M/s to 46.381M/s.
>
> I don't know why, but the benchmark result for "kprobe-multi-all" is much
> better in this version for the legacy case(without this series). In V2,
> the benchmark increase from 6.283M/s to 54.487M/s, but it become
> 12.151M/s to 46.381M/s in this version. Maybe it has some relation with
> the compiler optimization :/
>
> The result of this version should be more accurate, which is similar to
> Jiri's result: from 3.565 ± 0.047M/s to 11.553 ± 0.458M/s.
Hi Menglong,
BTW, fprobe itself is maintained in linux-trace tree, not bpf-next.
This improvement can be tested via tracefs.
echo 'f:allfunc *' >> /sys/kernel/tracing/dynamic_events
So, can you split this series in fprobe performance improvement[1/4] for
linux-trace and others ([2/4]-[4/4]) for bpf-next?
I'll pick the first one.
Thank you,
>
> Changes since V4:
>
> * remove unnecessary rcu_read_lock in fprobe_entry
>
> Changes since V3:
>
> * replace rhashtable_walk_enter with rhltable_walk_enter in the 1st patch
>
> Changes since V2:
>
> * some format optimization, and handle the error that returned from
> rhltable_insert in insert_fprobe_node for the 1st patch
> * add "kretprobe-multi-all" testcase to the 4th patch
> * attach a empty kprobe-multi prog to the kernel functions, which don't
> call incr_count(), to make the result more accurate in the 4th patch
>
> Changes Since V1:
>
> * use rhltable instead of rhashtable to handle the duplicate key.
>
> Menglong Dong (4):
> fprobe: use rhltable for fprobe_ip_table
> selftests/bpf: move get_ksyms and get_addrs to trace_helpers.c
> selftests/bpf: skip recursive functions for kprobe_multi
> selftests/bpf: add benchmark testing for kprobe-multi-all
>
> include/linux/fprobe.h | 3 +-
> kernel/trace/fprobe.c | 151 +++++++-----
> tools/testing/selftests/bpf/bench.c | 4 +
> .../selftests/bpf/benchs/bench_trigger.c | 54 ++++
> .../selftests/bpf/benchs/run_bench_trigger.sh | 4 +-
> .../bpf/prog_tests/kprobe_multi_test.c | 220 +----------------
> .../selftests/bpf/progs/trigger_bench.c | 12 +
> tools/testing/selftests/bpf/trace_helpers.c | 233 ++++++++++++++++++
> tools/testing/selftests/bpf/trace_helpers.h | 3 +
> 9 files changed, 398 insertions(+), 286 deletions(-)
>
> --
> 2.50.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-08-19 1:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-17 2:46 Menglong Dong
2025-08-17 2:46 ` [PATCH bpf-next v5 1/4] fprobe: use rhltable " Menglong Dong
2025-08-18 13:43 ` Jiri Olsa
2025-08-19 1:13 ` Menglong Dong
2025-08-19 2:11 ` Masami Hiramatsu
2025-08-19 2:26 ` Menglong Dong
2025-08-20 2:05 ` Herbert Xu
2025-08-17 2:46 ` [PATCH bpf-next v5 2/4] selftests/bpf: move get_ksyms and get_addrs to trace_helpers.c Menglong Dong
2025-08-17 2:46 ` [PATCH bpf-next v5 3/4] selftests/bpf: skip recursive functions for kprobe_multi Menglong Dong
2025-08-17 2:46 ` [PATCH bpf-next v5 4/4] selftests/bpf: add benchmark testing for kprobe-multi-all Menglong Dong
2025-08-19 1:48 ` Masami Hiramatsu [this message]
2025-08-19 2:01 ` [PATCH bpf-next v5 0/4] fprobe: use rhashtable for fprobe_ip_table Menglong Dong
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=20250819104850.1a903746f2eca854490e770b@kernel.org \
--to=mhiramat@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=menglong8.dong@gmail.com \
--cc=revest@chromium.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®