public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH stable 6.6 6.12 1/1] selftests/bpf: Check for timeout in perf_link test
@ 2025-06-09  5:29 Shung-Hsi Yu
  2025-06-11 13:16 ` Sasha Levin
  2025-06-20 15:52 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Shung-Hsi Yu @ 2025-06-09  5:29 UTC (permalink / raw)
  To: stable; +Cc: Ihor Solodrai, Andrii Nakryiko, Shung-Hsi Yu

From: Ihor Solodrai <ihor.solodrai@pm.me>

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 3a25f1c743a1..d940ff87fa08 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.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH stable 6.6 6.12 1/1] selftests/bpf: Check for timeout in perf_link test
  2025-06-09  5:29 [PATCH stable 6.6 6.12 1/1] selftests/bpf: Check for timeout in perf_link test Shung-Hsi Yu
@ 2025-06-11 13:16 ` Sasha Levin
  2025-06-20 15:52 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-11 13:16 UTC (permalink / raw)
  To: stable, shung-hsi.yu; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: e6c209da7e0e9aaf955a7b59e91ed78c2b6c96fb

WARNING: Author mismatch between patch and found commit:
Backport author: Shung-Hsi Yu<shung-hsi.yu@suse.com>
Commit author: Ihor Solodrai<ihor.solodrai@pm.me>

Status in newer kernel trees:
6.15.y | Present (exact SHA1)
6.14.y | Present (exact SHA1)
6.12.y | Not found

Note: The patch differs from the upstream commit:
---
1:  e6c209da7e0e9 ! 1:  8249587f33f76 selftests/bpf: Check for timeout in perf_link test
    @@ Commit message
         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>
     
      ## tools/testing/selftests/bpf/prog_tests/perf_link.c ##
     @@
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.12.y       |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH stable 6.6 6.12 1/1] selftests/bpf: Check for timeout in perf_link test
  2025-06-09  5:29 [PATCH stable 6.6 6.12 1/1] selftests/bpf: Check for timeout in perf_link test Shung-Hsi Yu
  2025-06-11 13:16 ` Sasha Levin
@ 2025-06-20 15:52 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-06-20 15:52 UTC (permalink / raw)
  To: Shung-Hsi Yu; +Cc: stable, Ihor Solodrai, Andrii Nakryiko

On Mon, Jun 09, 2025 at 01:29:38PM +0800, Shung-Hsi Yu wrote:
> From: Ihor Solodrai <ihor.solodrai@pm.me>
> 
> 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(-)
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-20 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09  5:29 [PATCH stable 6.6 6.12 1/1] selftests/bpf: Check for timeout in perf_link test Shung-Hsi Yu
2025-06-11 13:16 ` Sasha Levin
2025-06-20 15:52 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox