aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_maps.c
diff options
context:
space:
mode:
authorYucong Sun <fallentree@fb.com>2021-08-16 21:57:13 -0700
committerAndrii Nakryiko <andrii@kernel.org>2021-08-17 08:17:40 -0700
commit857f75ea845706a0ec65ce2239da519214a4451a (patch)
treef4804f3ab8c1872f8ac67950fd4e49b5332e5fbb /tools/testing/selftests/bpf/test_maps.c
parentselftests/bpf: Add exponential backoff to map_update_retriable in test_maps (diff)
downloadlinux-dev-857f75ea845706a0ec65ce2239da519214a4451a.tar.xz
linux-dev-857f75ea845706a0ec65ce2239da519214a4451a.zip
selftests/bpf: Add exponential backoff to map_delete_retriable in test_maps
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> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210817045713.3307985-1-fallentree@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/test_maps.c')
-rw-r--r--tools/testing/selftests/bpf/test_maps.c7
1 files changed, 6 insertions, 1 deletions
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--;
}