[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <11956701-DB1D-49E9-BD47-A9AC1E26F487@fb.com>
Date: Tue, 22 Dec 2020 23:58:31 +0000
From: Song Liu <songliubraving@...com>
To: Andrii Nakryiko <andrii@...nel.org>
CC: bpf <bpf@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
"daniel@...earbox.net" <daniel@...earbox.net>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf] selftests/bpf: work-around EBUSY errors from hashmap
update/delete
> On Dec 22, 2020, at 11:53 AM, Andrii Nakryiko <andrii@...nel.org> wrote:
>
> 20b6cc34ea74 ("bpf: Avoid hashtab deadlock with map_locked") introduced
> a possibility of getting EBUSY error on lock contention, which seems to happen
> very deterministically in test_maps when running 1024 threads on low-CPU
> machine. In libbpf CI case, it's a 2 CPU VM and it's hitting this 100% of the
> time. Work around by retrying on EBUSY (and EAGAIN, while we are at it) after
> a small sleep. sched_yield() is too agressive and fails even after 20 retries,
> so I went with usleep(1) for backoff.
>
> Also log actual error returned to make it easier to see what's going on.
>
> Fixes: 20b6cc34ea74 ("bpf: Avoid hashtab deadlock with map_locked")
> Cc: Song Liu <songliubraving@...com>
> Signed-off-by: Andrii Nakryiko <andrii@...nel.org>
Thanks for the fix!
Acked-by: Song Liu <songliubraving@...com>
With one minor nitpick below
> ---
> tools/testing/selftests/bpf/test_maps.c | 46 +++++++++++++++++++++----
> 1 file changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
> index 0ad3e6305ff0..809004f4995f 100644
> --- a/tools/testing/selftests/bpf/test_maps.c
> +++ b/tools/testing/selftests/bpf/test_maps.c
> @@ -1312,22 +1312,56 @@ static void test_map_stress(void)
> #define DO_UPDATE 1
> #define DO_DELETE 0
[...]
> + printf("error %d %d\n", err, errno);
> + assert(err == 0);
> + err = map_update_retriable(fd, &key, &value, BPF_EXIST, 20);
> + if (err)
> + printf("error %d %d\n", err, errno);
> + assert(err == 0);
> } else {
> - assert(bpf_map_delete_elem(fd, &key) == 0);
> + err = map_delete_retriable(fd, &key, 5);
nit: Why 5 here vs. 20 above?
> + if (err)
> + printf("error %d %d\n", err, errno);
> + assert(err == 0);
> }
> }
> }
> --
> 2.24.1
>
Powered by blists - more mailing lists