* [PATCH stable 6.1 v2 0/2] Fix perf_link failure
@ 2026-06-19 4:59 Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 1/2] selftests/bpf: Move get_time_ns to testing_helpers.h Shung-Hsi Yu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Shung-Hsi Yu @ 2026-06-19 4:59 UTC (permalink / raw)
To: stable; +Cc: Shung-Hsi Yu
This patchset address the perf_link failure in 6.1 with patch 2
"selftests/bpf: Check for timeout in perf_link test", which is already
part of newer stable releases.
Previous v1[1] of this patchset was missing get_time_ns() helper, and thus
will cause BPF selftests to fail during compilation. I have confirmed
that with these patches applied, BPF selftests compiles and passes[2].
1: https://lore.kernel.org/stable/20260618074114.16091-1-shung-hsi.yu@suse.com
2: https://github.com/kernel-patches/linux-stable/actions/runs/27805953461/job/82285741662
Ihor Solodrai (1):
selftests/bpf: Check for timeout in perf_link test
Jiri Olsa (1):
selftests/bpf: Move get_time_ns to testing_helpers.h
tools/testing/selftests/bpf/bench.h | 9 ---------
.../selftests/bpf/prog_tests/kprobe_multi_test.c | 8 --------
.../testing/selftests/bpf/prog_tests/perf_link.c | 15 +++++++++++++--
tools/testing/selftests/bpf/testing_helpers.h | 10 ++++++++++
4 files changed, 23 insertions(+), 19 deletions(-)
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH stable 6.1 v2 1/2] selftests/bpf: Move get_time_ns to testing_helpers.h
2026-06-19 4:59 [PATCH stable 6.1 v2 0/2] Fix perf_link failure Shung-Hsi Yu
@ 2026-06-19 4:59 ` Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 2/2] selftests/bpf: Check for timeout in perf_link test Shung-Hsi Yu
2026-06-20 11:54 ` [PATCH stable 6.1 v2 0/2] Fix perf_link failure Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Shung-Hsi Yu @ 2026-06-19 4:59 UTC (permalink / raw)
To: stable; +Cc: Shung-Hsi Yu, Jiri Olsa, Alexei Starovoitov
From: Jiri Olsa <jolsa@kernel.org>
commit 3830d04a7401f277185e4439eb259c1b13e76788 upstream.
We'd like to have single copy of get_time_ns used b bench and test_progs,
but we can't just include bench.h, because of conflicting 'struct env'
objects.
Moving get_time_ns to testing_helpers.h which is being included by both
bench and test_progs objects.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230809083440.3209381-19-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Stable-dep-of: e6c209da7e0e ("selftests/bpf: Check for timeout in perf_link test")
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
tools/testing/selftests/bpf/bench.h | 9 ---------
.../selftests/bpf/prog_tests/kprobe_multi_test.c | 8 --------
tools/testing/selftests/bpf/testing_helpers.h | 10 ++++++++++
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/tools/testing/selftests/bpf/bench.h b/tools/testing/selftests/bpf/bench.h
index 669593871483..2c94c57885af 100644
--- a/tools/testing/selftests/bpf/bench.h
+++ b/tools/testing/selftests/bpf/bench.h
@@ -79,15 +79,6 @@ void grace_period_latency_basic_stats(struct bench_res res[], int res_cnt,
void grace_period_ticks_basic_stats(struct bench_res res[], int res_cnt,
struct basic_stats *gp_stat);
-static inline __u64 get_time_ns(void)
-{
- struct timespec t;
-
- clock_gettime(CLOCK_MONOTONIC, &t);
-
- return (u64)t.tv_sec * 1000000000 + t.tv_nsec;
-}
-
static inline void atomic_inc(long *value)
{
(void)__atomic_add_fetch(value, 1, __ATOMIC_RELAXED);
diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
index 0d82e28aed1a..8086e2834646 100644
--- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
@@ -304,14 +304,6 @@ static void test_attach_api_fails(void)
kprobe_multi__destroy(skel);
}
-static inline __u64 get_time_ns(void)
-{
- struct timespec t;
-
- clock_gettime(CLOCK_MONOTONIC, &t);
- return (__u64) t.tv_sec * 1000000000 + t.tv_nsec;
-}
-
static size_t symbol_hash(const void *key, void *ctx __maybe_unused)
{
return str_hash((const char *) key);
diff --git a/tools/testing/selftests/bpf/testing_helpers.h b/tools/testing/selftests/bpf/testing_helpers.h
index 02e8c4efd028..c57349161cfa 100644
--- a/tools/testing/selftests/bpf/testing_helpers.h
+++ b/tools/testing/selftests/bpf/testing_helpers.h
@@ -7,6 +7,7 @@
#include <stdbool.h>
#include <bpf/bpf.h>
#include <bpf/libbpf.h>
+#include <time.h>
int parse_num_list(const char *s, bool **set, int *set_len);
__u32 link_info_prog_id(const struct bpf_link *link, struct bpf_link_info *info);
@@ -33,4 +34,13 @@ int load_bpf_testmod(bool verbose);
void unload_bpf_testmod(bool verbose);
int kern_sync_rcu(void);
+static inline __u64 get_time_ns(void)
+{
+ struct timespec t;
+
+ clock_gettime(CLOCK_MONOTONIC, &t);
+
+ return (u64)t.tv_sec * 1000000000 + t.tv_nsec;
+}
+
#endif /* __TESTING_HELPERS_H */
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH stable 6.1 v2 2/2] selftests/bpf: Check for timeout in perf_link test
2026-06-19 4:59 [PATCH stable 6.1 v2 0/2] Fix perf_link failure Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 1/2] selftests/bpf: Move get_time_ns to testing_helpers.h Shung-Hsi Yu
@ 2026-06-19 4:59 ` Shung-Hsi Yu
2026-06-20 11:54 ` [PATCH stable 6.1 v2 0/2] Fix perf_link failure Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Shung-Hsi Yu @ 2026-06-19 4:59 UTC (permalink / raw)
To: stable; +Cc: Shung-Hsi Yu, Ihor Solodrai, Andrii Nakryiko
From: Ihor Solodrai <ihor.solodrai@pm.me>
commit e6c209da7e0e9aaf955a7b59e91ed78c2b6c96fb upstream.
Recently perf_link test started unreliably failing on libbpf CI:
* https://github.com/libbpf/libbpf/actions/runs/11260672407/job/31312405473
* https://github.com/libbpf/libbpf/actions/runs/11260992334/job/31315514626
* https://github.com/libbpf/libbpf/actions/runs/11263162459/job/31320458251
Part of the test is running a dummy loop for a while and then checking
for a counter incremented by the test program.
Instead of waiting for an arbitrary number of loop iterations once,
check for the test counter in a loop and use get_time_ns() helper to
enforce a 100ms timeout.
v1: https://lore.kernel.org/bpf/zuRd072x9tumn2iN4wDNs5av0nu5nekMNV4PkR-YwCT10eFFTrUtZBRkLWFbrcCe7guvLStGQlhibo8qWojCO7i2-NGajes5GYIyynexD-w=@pm.me/
Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241011153104.249800-1-ihor.solodrai@pm.me
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
.../testing/selftests/bpf/prog_tests/perf_link.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/perf_link.c b/tools/testing/selftests/bpf/prog_tests/perf_link.c
index 224eba6fef2e..d734526d6a16 100644
--- a/tools/testing/selftests/bpf/prog_tests/perf_link.c
+++ b/tools/testing/selftests/bpf/prog_tests/perf_link.c
@@ -4,8 +4,12 @@
#include <pthread.h>
#include <sched.h>
#include <test_progs.h>
+#include "testing_helpers.h"
#include "test_perf_link.skel.h"
+#define BURN_TIMEOUT_MS 100
+#define BURN_TIMEOUT_NS BURN_TIMEOUT_MS * 1000000
+
static void burn_cpu(void)
{
volatile int j = 0;
@@ -32,6 +36,7 @@ void serial_test_perf_link(void)
int run_cnt_before, run_cnt_after;
struct bpf_link_info info;
__u32 info_len = sizeof(info);
+ __u64 timeout_time_ns;
/* create perf event */
memset(&attr, 0, sizeof(attr));
@@ -63,8 +68,14 @@ void serial_test_perf_link(void)
ASSERT_GT(info.prog_id, 0, "link_prog_id");
/* ensure we get at least one perf_event prog execution */
- burn_cpu();
- ASSERT_GT(skel->bss->run_cnt, 0, "run_cnt");
+ timeout_time_ns = get_time_ns() + BURN_TIMEOUT_NS;
+ while (true) {
+ burn_cpu();
+ if (skel->bss->run_cnt > 0)
+ break;
+ if (!ASSERT_LT(get_time_ns(), timeout_time_ns, "run_cnt_timeout"))
+ break;
+ }
/* perf_event is still active, but we close link and BPF program
* shouldn't be executed anymore
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH stable 6.1 v2 0/2] Fix perf_link failure
2026-06-19 4:59 [PATCH stable 6.1 v2 0/2] Fix perf_link failure Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 1/2] selftests/bpf: Move get_time_ns to testing_helpers.h Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 2/2] selftests/bpf: Check for timeout in perf_link test Shung-Hsi Yu
@ 2026-06-20 11:54 ` Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-06-20 11:54 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin, Shung-Hsi Yu
> [PATCH stable 6.1 v2 0/2] Fix perf_link failure
Queued the series for 6.1, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-20 11:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-19 4:59 [PATCH stable 6.1 v2 0/2] Fix perf_link failure Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 1/2] selftests/bpf: Move get_time_ns to testing_helpers.h Shung-Hsi Yu
2026-06-19 4:59 ` [PATCH stable 6.1 v2 2/2] selftests/bpf: Check for timeout in perf_link test Shung-Hsi Yu
2026-06-20 11:54 ` [PATCH stable 6.1 v2 0/2] Fix perf_link failure Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox