diff mbox series

[v1,bpf-next] selftests/bpf: Add exponential backoff to map_delete_retriable in test_maps

Message ID 20210817045713.3307985-1-fallentree@fb.com (mailing list archive)
State Accepted
Commit 857f75ea845706a0ec65ce2239da519214a4451a
Delegated to: BPF
Headers show
Series [v1,bpf-next] selftests/bpf: Add exponential backoff to map_delete_retriable in test_maps | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 10 maintainers not CCed: songliubraving@fb.com shuah@kernel.org daniel@iogearbox.net kafai@fb.com netdev@vger.kernel.org ast@kernel.org john.fastabend@gmail.com linux-kselftest@vger.kernel.org kpsingh@kernel.org yhs@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Yucong Sun Aug. 17, 2021, 4:57 a.m. UTC
Using a fixed delay of 1 microsecond has proven flaky in slow CPU environment,
e.g. Github Actions CI system. This patch adds exponential backoff with a cap
of 50ms to reduce the flakiness of the test. Initial delay is chosen at random
in the range [0ms, 5ms).

Signed-off-by: Yucong Sun <fallentree@fb.com>
---
 tools/testing/selftests/bpf/test_maps.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Andrii Nakryiko Aug. 17, 2021, 3:18 p.m. UTC | #1
On Mon, Aug 16, 2021 at 9:57 PM Yucong Sun <fallentree@fb.com> wrote:
>
> Using a fixed delay of 1 microsecond has proven flaky in slow CPU environment,
> e.g. Github Actions CI system. This patch adds exponential backoff with a cap
> of 50ms to reduce the flakiness of the test. Initial delay is chosen at random
> in the range [0ms, 5ms).
>
> Signed-off-by: Yucong Sun <fallentree@fb.com>
> ---

Thanks for the fast follow-up! Applied to bpf-next. Let's see what
pops up next :)

>  tools/testing/selftests/bpf/test_maps.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
> index 2caf58b40d40..340695d5d652 100644
> --- a/tools/testing/selftests/bpf/test_maps.c
> +++ b/tools/testing/selftests/bpf/test_maps.c
> @@ -1420,11 +1420,16 @@ static int map_update_retriable(int map_fd, const void *key, const void *value,
>
>  static int map_delete_retriable(int map_fd, const void *key, int attempts)
>  {
> +       int delay = rand() % MIN_DELAY_RANGE_US;
> +
>         while (bpf_map_delete_elem(map_fd, key)) {
>                 if (!attempts || (errno != EAGAIN && errno != EBUSY))
>                         return -errno;
>
> -               usleep(1);
> +               if (delay <= MAX_DELAY_US / 2)
> +                       delay *= 2;
> +
> +               usleep(delay);
>                 attempts--;
>         }
>
> --
> 2.30.2
>
patchwork-bot+netdevbpf@kernel.org Aug. 17, 2021, 3:20 p.m. UTC | #2
Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Mon, 16 Aug 2021 21:57:13 -0700 you wrote:
> Using a fixed delay of 1 microsecond has proven flaky in slow CPU environment,
> e.g. Github Actions CI system. This patch adds exponential backoff with a cap
> of 50ms to reduce the flakiness of the test. Initial delay is chosen at random
> in the range [0ms, 5ms).
> 
> Signed-off-by: Yucong Sun <fallentree@fb.com>
> 
> [...]

Here is the summary with links:
  - [v1,bpf-next] selftests/bpf: Add exponential backoff to map_delete_retriable in test_maps
    https://git.kernel.org/bpf/bpf-next/c/857f75ea8457

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index 2caf58b40d40..340695d5d652 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -1420,11 +1420,16 @@  static int map_update_retriable(int map_fd, const void *key, const void *value,
 
 static int map_delete_retriable(int map_fd, const void *key, int attempts)
 {
+	int delay = rand() % MIN_DELAY_RANGE_US;
+
 	while (bpf_map_delete_elem(map_fd, key)) {
 		if (!attempts || (errno != EAGAIN && errno != EBUSY))
 			return -errno;
 
-		usleep(1);
+		if (delay <= MAX_DELAY_US / 2)
+			delay *= 2;
+
+		usleep(delay);
 		attempts--;
 	}