From nobody Thu Apr 2 15:41:20 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B8D8377551; Tue, 24 Feb 2026 10:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771929615; cv=none; b=pUTcEetij8EF//w5p7BH9Df1ARto8Cnjso4lfFioGzXdp9DP2ok+6Ut9qQ1O5NAo3+rh9b38p8MW6YsZjfYzLXw2t8ziy2ELpaVoHtljKAkh4QpUw5tVaD/47m4TcMZn5lOmjyI9DPKSsfuiGisJbnq1etM0R6z0vTthtDECBy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771929615; c=relaxed/simple; bh=F+27PLKRsMR9oBOYaHEH2ngLd8FV0hMP80Zyg/41MHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PP7//xYjWEVED4EFBhdaCObK44C/rXiK1nVmIVZyn4luLUYsEMsrwAbj3ZDeVNiPHhom5Prd8iy4oBSUhkvea88vHSqPM1CVBBrno0NJn4o8qTJxk7l9TuFxxz9XuHNqBWSxDNGqr7/yRCXMd+cevYG0WdDaQPZ6ow0LcdbI+mU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bOCwEqF5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bOCwEqF5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6322AC116D0; Tue, 24 Feb 2026 10:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771929615; bh=F+27PLKRsMR9oBOYaHEH2ngLd8FV0hMP80Zyg/41MHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bOCwEqF51QTlIU+XhLgvUTQTmM594NK59hVXtqWieqVnu5HEmQpfQLiqFFoxHFied 24ITGEN3iQ/pHZeByxS3Y9TZhNwcOmo860OwcEik/IoS5px/jXFacviWxhBJNc6vn1 uslR9V7FLNAdUPOo2g8g/s8HsEcBRvgUHrBUvxK1Rzs0xHP2svYTb3Ct8CX/RVk6/v zw2Nx4PkWQiGB03Bt/+G57ywGzHKUdpj2zOpxFbV+Ix8BiRYCMlw6KHRIT0Jj43nAI E7MZl0Z0zcrjRI8xsCzqarUnf86yft3GI6czeBf8jnog8Mg6qdUzBeIrINb4XNotlb 7Y0f1aLR2v+9g== From: Jiri Olsa To: Andrii Nakryiko Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend Subject: [PATCHv5 bpf-next 5/5] selftests/bpf: Add usdt trigger bench Date: Tue, 24 Feb 2026 11:39:15 +0100 Message-ID: <20260224103915.1369690-6-jolsa@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260224103915.1369690-1-jolsa@kernel.org> References: <20260224103915.1369690-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Adding usdt trigger bench for usdt: trig-usdt-nop - usdt on top of nop1 instruction trig-usdt-nop5 - usdt on top of nop1/nop5 combo Adding it to benchs/run_bench_uprobes.sh script. Example run on x86_64 kernel with uprobe syscall: # ./benchs/run_bench_uprobes.sh usermode-count : 152.507 =C2=B1 0.098M/s syscall-count : 14.309 =C2=B1 0.093M/s uprobe-nop : 3.190 =C2=B1 0.012M/s uprobe-push : 3.057 =C2=B1 0.004M/s uprobe-ret : 1.095 =C2=B1 0.009M/s uprobe-nop5 : 7.305 =C2=B1 0.034M/s uretprobe-nop : 2.175 =C2=B1 0.005M/s uretprobe-push : 2.109 =C2=B1 0.003M/s uretprobe-ret : 0.945 =C2=B1 0.002M/s uretprobe-nop5 : 3.530 =C2=B1 0.006M/s usdt-nop : 3.235 =C2=B1 0.008M/s <-- added usdt-nop5 : 7.511 =C2=B1 0.045M/s <-- added Signed-off-by: Jiri Olsa --- tools/testing/selftests/bpf/Makefile | 2 + tools/testing/selftests/bpf/bench.c | 4 ++ .../selftests/bpf/benchs/bench_trigger.c | 60 +++++++++++++++++++ .../selftests/bpf/benchs/run_bench_uprobes.sh | 2 +- .../selftests/bpf/progs/trigger_bench.c | 10 +++- 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index 23857d17fc5b..8196128251d5 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -874,6 +874,8 @@ $(OUTPUT)/bench: $(OUTPUT)/bench.o \ $(OUTPUT)/bench_bpf_crypto.o \ $(OUTPUT)/bench_sockmap.o \ $(OUTPUT)/bench_lpm_trie_map.o \ + $(OUTPUT)/usdt_1.o \ + $(OUTPUT)/usdt_2.o \ # $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ diff --git a/tools/testing/selftests/bpf/bench.c b/tools/testing/selftests/= bpf/bench.c index 8368bd3a0665..029b3e21f438 100644 --- a/tools/testing/selftests/bpf/bench.c +++ b/tools/testing/selftests/bpf/bench.c @@ -541,6 +541,8 @@ 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; +extern const struct bench bench_trig_usdt_nop; +extern const struct bench bench_trig_usdt_nop5; #endif =20 extern const struct bench bench_rb_libbpf; @@ -617,6 +619,8 @@ static const struct bench *benchs[] =3D { &bench_trig_uretprobe_nop5, &bench_trig_uprobe_multi_nop5, &bench_trig_uretprobe_multi_nop5, + &bench_trig_usdt_nop, + &bench_trig_usdt_nop5, #endif /* ringbuf/perfbuf benchmarks */ &bench_rb_libbpf, diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c b/tools/tes= ting/selftests/bpf/benchs/bench_trigger.c index aeec9edd3851..2ee6a2df2c26 100644 --- a/tools/testing/selftests/bpf/benchs/bench_trigger.c +++ b/tools/testing/selftests/bpf/benchs/bench_trigger.c @@ -405,6 +405,23 @@ static void *uprobe_producer_nop5(void *input) uprobe_target_nop5(); return NULL; } + +void usdt_1(void); +void usdt_2(void); + +static void *uprobe_producer_usdt_nop(void *input) +{ + while (true) + usdt_1(); + return NULL; +} + +static void *uprobe_producer_usdt_nop5(void *input) +{ + while (true) + usdt_2(); + return NULL; +} #endif =20 static void usetup(bool use_retprobe, bool use_multi, void *target_addr) @@ -542,6 +559,47 @@ static void uretprobe_multi_nop5_setup(void) { usetup(true, true /* use_multi */, &uprobe_target_nop5); } + +static void usdt_setup(const char *name) +{ + struct bpf_link *link; + int err; + + setup_libbpf(); + + ctx.skel =3D 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 =3D trigger_bench__load(ctx.skel); + if (err) { + fprintf(stderr, "failed to load skeleton\n"); + exit(1); + } + + link =3D bpf_program__attach_usdt(ctx.skel->progs.bench_trigger_usdt, + 0 /*self*/, "/proc/self/exe", + "optimized_attach", name, NULL); + if (libbpf_get_error(link)) { + fprintf(stderr, "failed to attach optimized_attach:%s usdt probe\n", nam= e); + exit(1); + } + ctx.skel->links.bench_trigger_usdt =3D link; +} + +static void usdt_nop_setup(void) +{ + usdt_setup("usdt_1"); +} + +static void usdt_nop5_setup(void) +{ + usdt_setup("usdt_2"); +} #endif =20 const struct bench bench_trig_syscall_count =3D { @@ -609,4 +667,6 @@ 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"); +BENCH_TRIG_USERMODE(usdt_nop, usdt_nop, "usdt-nop"); +BENCH_TRIG_USERMODE(usdt_nop5, usdt_nop5, "usdt-nop5"); #endif diff --git a/tools/testing/selftests/bpf/benchs/run_bench_uprobes.sh b/tool= s/testing/selftests/bpf/benchs/run_bench_uprobes.sh index 03f55405484b..9ec59423b949 100755 --- a/tools/testing/selftests/bpf/benchs/run_bench_uprobes.sh +++ b/tools/testing/selftests/bpf/benchs/run_bench_uprobes.sh @@ -2,7 +2,7 @@ =20 set -eufo pipefail =20 -for i in usermode-count syscall-count {uprobe,uretprobe}-{nop,push,ret,nop= 5} +for i in usermode-count syscall-count {uprobe,uretprobe}-{nop,push,ret,nop= 5} usdt-nop usdt-nop5 do summary=3D$(sudo ./bench -w2 -d5 -a trig-$i | tail -n1 | cut -d'(' -f1 | = cut -d' ' -f3-) printf "%-15s: %s\n" $i "$summary" diff --git a/tools/testing/selftests/bpf/progs/trigger_bench.c b/tools/test= ing/selftests/bpf/progs/trigger_bench.c index 4ea0422d1042..3225b4aee8ff 100644 --- a/tools/testing/selftests/bpf/progs/trigger_bench.c +++ b/tools/testing/selftests/bpf/progs/trigger_bench.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2020 Facebook -#include +#include "vmlinux.h" #include #include #include #include "bpf_misc.h" +#include "bpf/usdt.bpf.h" =20 char _license[] SEC("license") =3D "GPL"; =20 @@ -180,3 +181,10 @@ int bench_trigger_rawtp(void *ctx) handle(ctx); return 0; } + +SEC("?usdt") +int bench_trigger_usdt(void *ctx) +{ + inc_counter(); + return 0; +} --=20 2.53.0