[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ8uoz1ftdghLf+vwhPu2_kuggGiRyG6jMMKc2tOCgxvqVamnw@mail.gmail.com>
Date: Mon, 13 Jun 2022 13:31:19 +0200
From: Magnus Karlsson <magnus.karlsson@...il.com>
To: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
Cc: bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Network Development <netdev@...r.kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@...el.com>,
Björn Töpel <bjorn@...nel.org>
Subject: Re: [PATCH bpf-next 08/10] selftests: xsk: rely on pkts_in_flight in wait_for_tx_completion()
On Fri, Jun 10, 2022 at 5:40 PM Maciej Fijalkowski
<maciej.fijalkowski@...el.com> wrote:
>
> Some of the drivers that implement support for AF_XDP Zero Copy (like
> ice) can have lazy approach for cleaning Tx descriptors. For ZC, when
> descriptor is cleaned, it is placed onto AF_XDP completion queue. This
> means that current implementation of wait_for_tx_completion() in
> xdpxceiver can get onto infinite loop, as some of the descriptors can
> never reach CQ.
>
> This function can be changed to rely on pkts_in_flight instead.
Acked-by: Magnus Karlsson <magnus.karlsson@...el.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
> ---
> tools/testing/selftests/bpf/xdpxceiver.c | 3 ++-
> tools/testing/selftests/bpf/xdpxceiver.h | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
> index 316f1dd338fc..c9385690af09 100644
> --- a/tools/testing/selftests/bpf/xdpxceiver.c
> +++ b/tools/testing/selftests/bpf/xdpxceiver.c
> @@ -965,7 +965,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb)
>
> static void wait_for_tx_completion(struct xsk_socket_info *xsk)
> {
> - while (xsk->outstanding_tx)
> + while (pkts_in_flight)
> complete_pkts(xsk, BATCH_SIZE);
> }
>
> @@ -1269,6 +1269,7 @@ static void *worker_testapp_validate_rx(void *arg)
> pthread_mutex_unlock(&pacing_mutex);
> }
>
> + pkts_in_flight = 0;
> pthread_exit(NULL);
> }
>
> diff --git a/tools/testing/selftests/bpf/xdpxceiver.h b/tools/testing/selftests/bpf/xdpxceiver.h
> index b7aa6c7cf2be..f364a92675f8 100644
> --- a/tools/testing/selftests/bpf/xdpxceiver.h
> +++ b/tools/testing/selftests/bpf/xdpxceiver.h
> @@ -170,6 +170,6 @@ pthread_barrier_t barr;
> pthread_mutex_t pacing_mutex = PTHREAD_MUTEX_INITIALIZER;
> pthread_cond_t pacing_cond = PTHREAD_COND_INITIALIZER;
>
> -int pkts_in_flight;
> +volatile int pkts_in_flight;
>
> #endif /* XDPXCEIVER_H */
> --
> 2.27.0
>
Powered by blists - more mailing lists