@@ -526,6 +526,7 @@ 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;
+extern const struct bench bench_trig_usdt;
extern const struct bench bench_rb_libbpf;
extern const struct bench bench_rb_custom;
@@ -586,6 +587,7 @@ static const struct bench *benchs[] = {
&bench_trig_uretprobe_multi_push,
&bench_trig_uprobe_multi_ret,
&bench_trig_uretprobe_multi_ret,
+ &bench_trig_usdt,
/* ringbuf/perfbuf benchmarks */
&bench_rb_libbpf,
&bench_rb_custom,
@@ -8,6 +8,7 @@
#include "bench.h"
#include "trigger_bench.skel.h"
#include "trace_helpers.h"
+#include "../sdt.h"
#define MAX_TRIG_BATCH_ITERS 1000
@@ -333,6 +334,13 @@ static void *uprobe_producer_ret(void *input)
return NULL;
}
+static void *uprobe_producer_usdt(void *input)
+{
+ while (true)
+ STAP_PROBE(trigger, usdt);
+ return NULL;
+}
+
static void usetup(bool use_retprobe, bool use_multi, void *target_addr)
{
size_t uprobe_offset;
@@ -383,6 +391,37 @@ static void usetup(bool use_retprobe, bool use_multi, void *target_addr)
}
}
+static void __usdt_setup(const char *provider, const char *name)
+{
+ struct bpf_link *link;
+ int err;
+
+ setup_libbpf();
+
+ ctx.skel = trigger_bench__open();
+ if (!ctx.skel) {
+ fprintf(stderr, "failed to open skeleton\n");
+ exit(1);
+ }
+
+ bpf_program__set_autoload(ctx.skel->progs.bench_trigger_usdt, true);
+
+ err = trigger_bench__load(ctx.skel);
+ if (err) {
+ fprintf(stderr, "failed to load skeleton\n");
+ exit(1);
+ }
+
+ link = bpf_program__attach_usdt(ctx.skel->progs.bench_trigger_usdt,
+ -1 /* all PIDs */, "/proc/self/exe",
+ provider, name, NULL);
+ if (!link) {
+ fprintf(stderr, "failed to attach uprobe!\n");
+ exit(1);
+ }
+ ctx.skel->links.bench_trigger_usdt = link;
+}
+
static void usermode_count_setup(void)
{
ctx.usermode_counters = true;
@@ -448,6 +487,11 @@ static void uretprobe_multi_ret_setup(void)
usetup(true, true /* use_multi */, &uprobe_target_ret);
}
+static void usdt_setup(void)
+{
+ __usdt_setup("trigger", "usdt");
+}
+
const struct bench bench_trig_syscall_count = {
.name = "trig-syscall-count",
.validate = trigger_validate,
@@ -506,3 +550,4 @@ 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");
+BENCH_TRIG_USERMODE(usdt, usdt, "usdt");
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2020 Facebook
-#include <linux/bpf.h>
+#include "vmlinux.h"
#include <asm/unistd.h>
#include <bpf/bpf_helpers.h>
+#include <bpf/usdt.bpf.h>
#include <bpf/bpf_tracing.h>
#include "bpf_misc.h"
@@ -138,3 +139,10 @@ int bench_trigger_rawtp(void *ctx)
inc_counter();
return 0;
}
+
+SEC("?usdt")
+int bench_trigger_usdt(struct pt_regs *ctx)
+{
+ inc_counter();
+ return 0;
+}
Adding usdt trigger bench to meassure optimized usdt probes. Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- tools/testing/selftests/bpf/bench.c | 2 + .../selftests/bpf/benchs/bench_trigger.c | 45 +++++++++++++++++++ .../selftests/bpf/progs/trigger_bench.c | 10 ++++- 3 files changed, 56 insertions(+), 1 deletion(-)