mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 14:42:08 +02:00
selftests/bpf: Add 5-byte NOP uprobe trigger benchmark
Add a 5-byte NOP uprobe trigger benchmark (x86_64 specific) to measure uprobes/uretprobes on top of NOP5 instructions. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Song Liu <songliubraving@fb.com> Cc: Yonghong Song <yhs@fb.com> Cc: John Fastabend <john.fastabend@gmail.com> Cc: Hao Luo <haoluo@google.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Alan Maguire <alan.maguire@oracle.com> Link: https://lore.kernel.org/r/20250414083647.1234007-2-jolsa@kernel.org
This commit is contained in:
parent
610f6e14c2
commit
fe8e5a3215
|
|
@ -526,6 +526,12 @@ extern const struct bench bench_trig_uprobe_multi_push;
|
|||
extern const struct bench bench_trig_uretprobe_multi_push;
|
||||
extern const struct bench bench_trig_uprobe_multi_ret;
|
||||
extern const struct bench bench_trig_uretprobe_multi_ret;
|
||||
#ifdef __x86_64__
|
||||
extern const struct bench bench_trig_uprobe_nop5;
|
||||
extern const struct bench bench_trig_uretprobe_nop5;
|
||||
extern const struct bench bench_trig_uprobe_multi_nop5;
|
||||
extern const struct bench bench_trig_uretprobe_multi_nop5;
|
||||
#endif
|
||||
|
||||
extern const struct bench bench_rb_libbpf;
|
||||
extern const struct bench bench_rb_custom;
|
||||
|
|
@ -586,6 +592,12 @@ static const struct bench *benchs[] = {
|
|||
&bench_trig_uretprobe_multi_push,
|
||||
&bench_trig_uprobe_multi_ret,
|
||||
&bench_trig_uretprobe_multi_ret,
|
||||
#ifdef __x86_64__
|
||||
&bench_trig_uprobe_nop5,
|
||||
&bench_trig_uretprobe_nop5,
|
||||
&bench_trig_uprobe_multi_nop5,
|
||||
&bench_trig_uretprobe_multi_nop5,
|
||||
#endif
|
||||
/* ringbuf/perfbuf benchmarks */
|
||||
&bench_rb_libbpf,
|
||||
&bench_rb_custom,
|
||||
|
|
|
|||
|
|
@ -333,6 +333,20 @@ static void *uprobe_producer_ret(void *input)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
__nocf_check __weak void uprobe_target_nop5(void)
|
||||
{
|
||||
asm volatile (".byte 0x0f, 0x1f, 0x44, 0x00, 0x00");
|
||||
}
|
||||
|
||||
static void *uprobe_producer_nop5(void *input)
|
||||
{
|
||||
while (true)
|
||||
uprobe_target_nop5();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usetup(bool use_retprobe, bool use_multi, void *target_addr)
|
||||
{
|
||||
size_t uprobe_offset;
|
||||
|
|
@ -448,6 +462,28 @@ static void uretprobe_multi_ret_setup(void)
|
|||
usetup(true, true /* use_multi */, &uprobe_target_ret);
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
static void uprobe_nop5_setup(void)
|
||||
{
|
||||
usetup(false, false /* !use_multi */, &uprobe_target_nop5);
|
||||
}
|
||||
|
||||
static void uretprobe_nop5_setup(void)
|
||||
{
|
||||
usetup(true, false /* !use_multi */, &uprobe_target_nop5);
|
||||
}
|
||||
|
||||
static void uprobe_multi_nop5_setup(void)
|
||||
{
|
||||
usetup(false, true /* use_multi */, &uprobe_target_nop5);
|
||||
}
|
||||
|
||||
static void uretprobe_multi_nop5_setup(void)
|
||||
{
|
||||
usetup(true, true /* use_multi */, &uprobe_target_nop5);
|
||||
}
|
||||
#endif
|
||||
|
||||
const struct bench bench_trig_syscall_count = {
|
||||
.name = "trig-syscall-count",
|
||||
.validate = trigger_validate,
|
||||
|
|
@ -506,3 +542,9 @@ BENCH_TRIG_USERMODE(uprobe_multi_ret, ret, "uprobe-multi-ret");
|
|||
BENCH_TRIG_USERMODE(uretprobe_multi_nop, nop, "uretprobe-multi-nop");
|
||||
BENCH_TRIG_USERMODE(uretprobe_multi_push, push, "uretprobe-multi-push");
|
||||
BENCH_TRIG_USERMODE(uretprobe_multi_ret, ret, "uretprobe-multi-ret");
|
||||
#ifdef __x86_64__
|
||||
BENCH_TRIG_USERMODE(uprobe_nop5, nop5, "uprobe-nop5");
|
||||
BENCH_TRIG_USERMODE(uretprobe_nop5, nop5, "uretprobe-nop5");
|
||||
BENCH_TRIG_USERMODE(uprobe_multi_nop5, nop5, "uprobe-multi-nop5");
|
||||
BENCH_TRIG_USERMODE(uretprobe_multi_nop5, nop5, "uretprobe-multi-nop5");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
set -eufo pipefail
|
||||
|
||||
for i in usermode-count syscall-count {uprobe,uretprobe}-{nop,push,ret}
|
||||
for i in usermode-count syscall-count {uprobe,uretprobe}-{nop,push,ret,nop5}
|
||||
do
|
||||
summary=$(sudo ./bench -w2 -d5 -a trig-$i | tail -n1 | cut -d'(' -f1 | cut -d' ' -f3-)
|
||||
printf "%-15s: %s\n" $i "$summary"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user