From nobody Sun Apr 5 13:23:29 2026 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64EFE241690 for ; Tue, 24 Mar 2026 04:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774327801; cv=none; b=XLjHFGL/ncRtBxko3RL9sfn9E1ySZZjB+SH0jUcxaD4iMetNh1hoSpjU39BVDnZTJTJswbOz5roDY7QElW+Q2IV1tTLbyoq67b+sHQtq5qL1Jk6qpraCNLuDV/PjpkJmcl3DybeC/lGmRq0+BeIEMGVHH53Ht3lKsIqzKb2bx6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774327801; c=relaxed/simple; bh=ftegVYCo78uMSqHnP0Y4PRhKxxJ+BFfvqzvQcWQEpuc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SrgbKe8U9HzfV7DdaVkfPG5Oup820l2aA9qHAwxkPh89iejFNN3OFGaNljotPhT0J0OPno4wQy9HRSKZerdbxXHQWaHeQD3MDGr9AGx7bwlzl2EE49OwLfK9agrBMDz0kUW5Ps6Gvr/d3QJp60NuInHCzsboQhGaWy4jnXdtLfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pbiid56w; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pbiid56w" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-79801df3e42so63543037b3.0 for ; Mon, 23 Mar 2026 21:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774327799; x=1774932599; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uGicTH0momhfy97qEFkEkUQzNyCBTGeoKeJkQ/iSw0A=; b=pbiid56w0b0flFqlH1PmzFQ7am2BDkoJjtq2vWASUp7qDb3QZs/Z0EFlgqJAoM/Z08 iAUqK+cxZJVVDHQUN40iMkCexwBUGTRIp5wvEj+lOnf49XIezSx8FDRTzaH0jBzwmb3r TXZGav8ynpZHZ282f+LWLkOBjwzMPkv/4x5DTxN3YEkZ/SyVmm7Cs5SLZjcqX7+dtdvA gbO2r6x0MY8jPOBUstlo58tGJM4Rz5iB6j+zHZXb5UYuW9tJRoGAeP4HqIIgRSJMfdL6 dEAE2cXvjkXDqN7+DRj8dxw81b4CNhdUrpHgk0UHuhk3ITcSzoRTyj9S9VlY//3SDz4Q ankw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774327799; x=1774932599; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uGicTH0momhfy97qEFkEkUQzNyCBTGeoKeJkQ/iSw0A=; b=eeQHBgQTIEbQNPjDPz44Tt2YokQYmmFDf6uPZeFR6VJhhYni84Vy1dtTZ/7+WMqyzu IKtnXi6cxfyp7e0kDkpxRxolkdDY+5lRC9lUeMb52Ed+6Hz46SoS6evP2V58jS4DHrh1 Y341TfohdUoAf0UEhbehOfid6YqzV5ove6NaLdK3r7uxeSPUAy6h+D5+58j+Z8dmlAEM o42ChKwrGYIrRTF1HFzemUrBFb+G2k1aYnF1aWGpjVXBOKyxd6rWp8kgyNG6enrwaZGT ib5LwLqq0JiZvoPGLCLHignr7O/3EQiPwhJHpQNAyDr5oxvCXNiL51IYHg7GfzrxNdyr XvWA== X-Forwarded-Encrypted: i=1; AJvYcCWwXGfVuCUAgpIrpNX6CTfRmXMylqdCwpHT3FB/ZmbzJ+l4e7hc27YF+I6Oqu8mgsa4brSl5KWLFqSo9Sk=@vger.kernel.org X-Gm-Message-State: AOJu0YxLkXDuib9wzvae9fTuJXLkAmOI+m5NEpEIxzBDjLS9WxRxASj4 mvHd7ADDJlCn//SSXmLSBMYhSONCaCJ6g+s5a0FXNCnYGYoSpC6aL+83 X-Gm-Gg: ATEYQzzx3hsbz+C+8heFqSfmrQaWhRw8wRkxYZ9zjvJjj2G1ODKSe5kFB2aAkvpCKtk slcm8yPBmEEePJw97Vncr/vDQpPlEPJgTFpVvC75W0v4CvzvkQ+Y4D48X03HKGOBjuWjJHBNaE8 bnvaidy+rpIgW8wqwErEjEY4HeFyUU4Uq7nZ0jEHHx/g5rY8MeMZE9U+AZMC2JwvZIGYBc1OjvY ZhKvZeA9/YG9u9bcqYprfy0DBYV9oz+33AKlGNsuPa3lSNlumTWH1ms48l+XjQqNGnR7rmNPNX3 dJGheV0OilJxpv12/AbKLM7epPZxTP7QK9xL5UivAOy0JErFiSa6iKacogq7Ow9kD+aJSJ+pYOm qEPeEENCrycqdZuaQkikaR7RETb3DkdAZGkcU8CCrFNpzuCMW65ycIEge5zeB3vQCgokJlrFXTZ irM4DyYlaOEYwm8oVac6YXlF2jkYvAyt1bhQhawqUEKh/JQWfeXBNxF3WC+OaSCh2FrSXCuWQ5S XJRoRk4F6CfC/852Q+g7+Q2ZHd8YP3csue6GzpPgrkGhDsHpf6CgavOGg6rnsLIAWS13G0OjZqp u162WPSIghFfvgAsjg== X-Received: by 2002:a05:690c:12:b0:79a:c5b5:d094 with SMTP id 00721157ae682-79ac5b5e61cmr6816317b3.22.1774327799343; Mon, 23 Mar 2026 21:49:59 -0700 (PDT) Received: from u2404-VMware-Virtual-Platform.localdomain (108-214-96-168.lightspeed.sntcca.sbcglobal.net. [108.214.96.168]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79a903f82e6sm70028857b3.17.2026.03.23.21.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 21:49:58 -0700 (PDT) From: Sun Jian To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, shuah@kernel.org, paul.chaignon@gmail.com, mykyta.yatsenko5@gmail.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Sun Jian Subject: [PATCH v4] selftests/bpf: move trampoline_count to dedicated bpf_testmod target Date: Tue, 24 Mar 2026 12:49:49 +0800 Message-ID: <20260324044949.869801-1-sun.jian.kdev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" trampoline_count fills all trampoline attachment slots for a single target function and verifies that one extra attach fails with -E2BIG. It currently targets bpf_modify_return_test, which is also used by other selftests such as modify_return, get_func_ip_test, and get_func_args_test. When such tests run in parallel, they can contend for the same per-function trampoline quota and cause unexpected attach failures. This issue is currently masked by harness serialization. Move trampoline_count to a dedicated bpf_testmod target and register it for fmod_ret attachment. Also route the final trigger through trigger_module_test_read(), so the execution path exercises the same dedicated target. This keeps the test semantics unchanged while isolating it from other selftests, so it no longer needs to run in serial mode. Remove the TODO comment as well. Tested: ./test_progs -t trampoline_count -vv ./test_progs -j$(nproc) -t trampoline_count -vv ./test_progs -j$(nproc) -t \ trampoline_count,modify_return,get_func_ip_test,get_func_args_test -vv 20 runs of: ./test_progs -j$(nproc) -t \ trampoline_count,modify_return,get_func_ip_test,get_func_args_test Signed-off-by: Sun Jian Acked-by: Jiri Olsa --- Link: https://lore.kernel.org/bpf/20260320074150.628094-1-sun.jian.kdev@gma= il.com/ v4: - simplify the dedicated trampoline_count target and its trigger path - simplify the associated fentry/fmod_ret/fexit test program signatures - reduce the final trigger to a plain ASSERT_OK() - drop Suggested-by per Jiri v3: - route the final trigger through trigger_module_test_read() and make bpf_testmod_test_read() call the dedicated trampoline_count target v2: - rewrite the subject to describe the change - resend with the correct patch content .../bpf/prog_tests/trampoline_count.c | 17 +++-------------- .../bpf/progs/test_trampoline_count.c | 12 ++++++------ .../selftests/bpf/test_kmods/bpf_testmod.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/trampoline_count.c b/to= ols/testing/selftests/bpf/prog_tests/trampoline_count.c index 6cd7349d4a2b..7321850db75f 100644 --- a/tools/testing/selftests/bpf/prog_tests/trampoline_count.c +++ b/tools/testing/selftests/bpf/prog_tests/trampoline_count.c @@ -30,16 +30,14 @@ static struct bpf_program *load_prog(char *file, char *= name, struct inst *inst) return prog; } =20 -/* TODO: use different target function to run in concurrent mode */ -void serial_test_trampoline_count(void) +void test_trampoline_count(void) { char *file =3D "test_trampoline_count.bpf.o"; char *const progs[] =3D { "fentry_test", "fmod_ret_test", "fexit_test" }; - int bpf_max_tramp_links, err, i, prog_fd; + int bpf_max_tramp_links, i; struct bpf_program *prog; struct bpf_link *link; struct inst *inst; - LIBBPF_OPTS(bpf_test_run_opts, opts); =20 bpf_max_tramp_links =3D get_bpf_max_tramp_links(); if (!ASSERT_GE(bpf_max_tramp_links, 1, "bpf_max_tramp_links")) @@ -80,16 +78,7 @@ void serial_test_trampoline_count(void) goto cleanup; =20 /* and finally execute the probe */ - prog_fd =3D bpf_program__fd(prog); - if (!ASSERT_GE(prog_fd, 0, "bpf_program__fd")) - goto cleanup; - - err =3D bpf_prog_test_run_opts(prog_fd, &opts); - if (!ASSERT_OK(err, "bpf_prog_test_run_opts")) - goto cleanup; - - ASSERT_EQ(opts.retval & 0xffff, 33, "bpf_modify_return_test.result"); - ASSERT_EQ(opts.retval >> 16, 2, "bpf_modify_return_test.side_effect"); + ASSERT_OK(trigger_module_test_read(256), "trigger_module_test_read"); =20 cleanup: for (; i >=3D 0; i--) { diff --git a/tools/testing/selftests/bpf/progs/test_trampoline_count.c b/to= ols/testing/selftests/bpf/progs/test_trampoline_count.c index 7765720da7d5..02f52806b1b2 100644 --- a/tools/testing/selftests/bpf/progs/test_trampoline_count.c +++ b/tools/testing/selftests/bpf/progs/test_trampoline_count.c @@ -3,20 +3,20 @@ #include #include =20 -SEC("fentry/bpf_modify_return_test") -int BPF_PROG(fentry_test, int a, int *b) +SEC("fentry/bpf_testmod_trampoline_count_test") +int BPF_PROG(fentry_test) { return 0; } =20 -SEC("fmod_ret/bpf_modify_return_test") -int BPF_PROG(fmod_ret_test, int a, int *b, int ret) +SEC("fmod_ret/bpf_testmod_trampoline_count_test") +int BPF_PROG(fmod_ret_test, int ret) { return 0; } =20 -SEC("fexit/bpf_modify_return_test") -int BPF_PROG(fexit_test, int a, int *b, int ret) +SEC("fexit/bpf_testmod_trampoline_count_test") +int BPF_PROG(fexit_test, int ret) { return 0; } diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/t= esting/selftests/bpf/test_kmods/bpf_testmod.c index e62c6b78657f..9caf9ffa1bb0 100644 --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c @@ -470,6 +470,11 @@ noinline void bpf_testmod_stacktrace_test_1(void) =20 int bpf_testmod_fentry_ok; =20 +noinline int bpf_testmod_trampoline_count_test(void) +{ + return 0; +} + noinline ssize_t bpf_testmod_test_read(struct file *file, struct kobject *kobj, const struct bin_attribute *bin_attr, @@ -548,6 +553,8 @@ bpf_testmod_test_read(struct file *file, struct kobject= *kobj, 21, 22, 23, 24, 25, 26) !=3D 231) goto out; =20 + bpf_testmod_trampoline_count_test(); + bpf_testmod_stacktrace_test_1(); =20 bpf_testmod_fentry_ok =3D 1; @@ -1843,6 +1850,16 @@ struct bpf_struct_ops testmod_multi_st_ops =3D { =20 extern int bpf_fentry_test1(int a); =20 +BTF_KFUNCS_START(bpf_testmod_trampoline_count_ids) +BTF_ID_FLAGS(func, bpf_testmod_trampoline_count_test) +BTF_KFUNCS_END(bpf_testmod_trampoline_count_ids) + +static const struct +btf_kfunc_id_set bpf_testmod_trampoline_count_fmodret_set =3D { + .owner =3D THIS_MODULE, + .set =3D &bpf_testmod_trampoline_count_ids, +}; + static int bpf_testmod_init(void) { const struct btf_id_dtor_kfunc bpf_testmod_dtors[] =3D { @@ -1859,6 +1876,7 @@ static int bpf_testmod_init(void) ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_test= mod_kfunc_set); ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, &bpf_test= mod_kfunc_set); ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, &bpf_t= estmod_kfunc_set); + ret =3D ret ?: register_btf_fmodret_id_set(&bpf_testmod_trampoline_count_= fmodret_set); ret =3D ret ?: register_bpf_struct_ops(&bpf_bpf_testmod_ops, bpf_testmod_= ops); ret =3D ret ?: register_bpf_struct_ops(&bpf_testmod_ops2, bpf_testmod_ops= 2); ret =3D ret ?: register_bpf_struct_ops(&bpf_testmod_ops3, bpf_testmod_ops= 3); base-commit: 8a30aeb0d1b4e4aaf7f7bae72f20f2ae75385ccb --=20 2.43.0