Commit 857f75ea authored by Yucong Sun's avatar Yucong Sun Committed by Andrii Nakryiko

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: default avatarYucong Sun <fallentree@fb.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210817045713.3307985-1-fallentree@fb.com
parent 3c3bd542
......@@ -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--;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment