Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0433C636CC for ; Tue, 31 Jan 2023 16:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbjAaQXN (ORCPT ); Tue, 31 Jan 2023 11:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjAaQXL (ORCPT ); Tue, 31 Jan 2023 11:23:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0157830F3 for ; Tue, 31 Jan 2023 08:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675182143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gbg+AzhWEGt3wVxcWkSCdqk5Y0vGygpbNeSX8uKNpq0=; b=h4oRS17MNG8uBZipSdiRV8MBYw5aS0jZ9MZS85x8ZPn+97ockHCeWIyGZ7vLqLCpvfZUvv UXOn5iad/rVv19XXEuEwzUAbbcI/V+RjlSr6JZVrGEUytu8TbGMj46FbqaeqRKCyRAwrbJ DS+ELwOVYfkN8sRv6fITLHCb6Ozlduw= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-575-AXTPI6rUNc-z9quP67L_ww-1; Tue, 31 Jan 2023 11:22:22 -0500 X-MC-Unique: AXTPI6rUNc-z9quP67L_ww-1 Received: by mail-ua1-f69.google.com with SMTP id 89-20020a9f26e2000000b004183c5c5b7aso5916531uay.10 for ; Tue, 31 Jan 2023 08:22:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Gbg+AzhWEGt3wVxcWkSCdqk5Y0vGygpbNeSX8uKNpq0=; b=y3J7b7wG4gZtm3RQ66uhpK3tL4eNfGSHY8q9PrilZKKvQNQjb5wfZ9AJnKV+MBo2+U +83Tt0VzaEaxovfLYvs4DoFAGOGx74aKpfbkSLu6BeKvHgecB9JlM+HHzTGDYj5Xv4zr NJ962PXyqbJglkaISFbHzgC1Ks7Oi14OoDp+ujLiXPoFkL+137eFFpIj4oe0mJN0A2It xZ9sFjo+/t7yvFjWUaFYgS1UvobvNBfdu/L1GB+2rgmkFt56goqInTf5eU+JxlgLkEAN ODr9/WrzW/Tb6UZuaZwVqGsSQOo3sny4+53bJqJG2Ju3uUzrTfwewMm0qP880uIGrMi+ ED6A== X-Gm-Message-State: AFqh2kqU4Xo8z9/5Q1bGnyPxEeoIhPx8HEXD7957TC2OVX4SsD0Ks9Ym KZy0JTka2w18RNQ8PZtAkzKRAl27/B+rqObersdb2N57SWQg+TgRMmKA7iEU5Vxq2gf9KWmLN5L 5ckIlcD7DT3ual05wCSBhoVTU X-Received: by 2002:a05:6102:334c:b0:3c8:bfe0:d5ec with SMTP id j12-20020a056102334c00b003c8bfe0d5ecmr7530685vse.0.1675182140145; Tue, 31 Jan 2023 08:22:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXufopaXJrOQK8xf5PnImViVfo192XMgd8vmUeO5DkaGWebI8ksfnEA+4C/0qsZ9m08m5hlpTg== X-Received: by 2002:a05:6102:334c:b0:3c8:bfe0:d5ec with SMTP id j12-20020a056102334c00b003c8bfe0d5ecmr7530665vse.0.1675182139834; Tue, 31 Jan 2023 08:22:19 -0800 (PST) Received: from gerbillo.redhat.com (146-241-113-28.dyn.eolo.it. [146.241.113.28]) by smtp.gmail.com with ESMTPSA id 136-20020a37068e000000b00719d9f823c4sm7765895qkg.34.2023.01.31.08.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 08:22:19 -0800 (PST) Message-ID: <17e062f077235b949090cba893c91f5637cc1f0e.camel@redhat.com> Subject: Re: [PATCH v2 4/4] selftests: net: udpgso_bench_tx: Cater for pending datagrams zerocopy benchmarking From: Paolo Abeni To: Andrei Gherzan Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Shuah Khan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 31 Jan 2023 17:22:16 +0100 In-Reply-To: References: <20230131130412.432549-1-andrei.gherzan@canonical.com> <20230131130412.432549-4-andrei.gherzan@canonical.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-01-31 at 15:08 +0000, Andrei Gherzan wrote: > On 23/01/31 03:51PM, Paolo Abeni wrote: > > On Tue, 2023-01-31 at 13:04 +0000, Andrei Gherzan wrote: > > > The test tool can check that the zerocopy number of completions value= is > > > valid taking into consideration the number of datagram send calls. Th= is can > > > catch the system into a state where the datagrams are still in the sy= stem > > > (for example in a qdisk, waiting for the network interface to return = a > > > completion notification, etc). > > >=20 > > > This change adds a retry logic of computing the number of completions= up to > > > a configurable (via CLI) timeout (default: 2 seconds). > > >=20 > > > Signed-off-by: Andrei Gherzan > > > --- > > > tools/testing/selftests/net/udpgso_bench_tx.c | 38 +++++++++++++++--= -- > > > 1 file changed, 30 insertions(+), 8 deletions(-) > > >=20 > > > diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/te= sting/selftests/net/udpgso_bench_tx.c > > > index b47b5c32039f..5a29b5f24023 100644 > > > --- a/tools/testing/selftests/net/udpgso_bench_tx.c > > > +++ b/tools/testing/selftests/net/udpgso_bench_tx.c > > > @@ -62,6 +62,7 @@ static int cfg_payload_len =3D (1472 * 42); > > > static int cfg_port =3D 8000; > > > static int cfg_runtime_ms =3D -1; > > > static bool cfg_poll; > > > +static int cfg_poll_loop_timeout_ms =3D 2000; > > > static bool cfg_segment; > > > static bool cfg_sendmmsg; > > > static bool cfg_tcp; > > > @@ -235,16 +236,17 @@ static void flush_errqueue_recv(int fd) > > > } > > > } > > > =20 > > > -static void flush_errqueue(int fd, const bool do_poll) > > > +static void flush_errqueue(int fd, const bool do_poll, > > > + unsigned long poll_timeout, const bool poll_err) > > > { > > > if (do_poll) { > > > struct pollfd fds =3D {0}; > > > int ret; > > > =20 > > > fds.fd =3D fd; > > > - ret =3D poll(&fds, 1, 500); > > > + ret =3D poll(&fds, 1, poll_timeout); > > > if (ret =3D=3D 0) { > > > - if (cfg_verbose) > > > + if ((cfg_verbose) && (poll_err)) > > > fprintf(stderr, "poll timeout\n"); > > > } else if (ret < 0) { > > > error(1, errno, "poll"); > > > @@ -254,6 +256,22 @@ static void flush_errqueue(int fd, const bool do= _poll) > > > flush_errqueue_recv(fd); > > > } > > > =20 > > > +static void flush_errqueue_retry(int fd, const bool do_poll, unsigne= d long num_sends) > > > +{ > > > + unsigned long tnow, tstop; > > > + bool first_try =3D true; > > > + > > > + tnow =3D gettimeofday_ms(); > > > + tstop =3D tnow + cfg_poll_loop_timeout_ms; > > > + do { > > > + flush_errqueue(fd, do_poll, tstop - tnow, first_try); > > > + first_try =3D false; > > > + if (!do_poll) > > > + usleep(1000); // a throttling delay if polling is enabled > >=20 > > Even if the kernel codying style is not very strictly enforced for > > self-tests, please avoid c++ style comments. > >=20 > > More importantly, as Willem noded, this function is always called with > > do_poll =3D=3D true. You should drop such argument and the related bran= ch > > above. >=20 > Agreed. I will drop. >=20 > >=20 > > > + tnow =3D gettimeofday_ms(); > > > + } while ((stat_zcopies !=3D num_sends) && (tnow < tstop)); > > > +} > > > + > > > static int send_tcp(int fd, char *data) > > > { > > > int ret, done =3D 0, count =3D 0; > > > @@ -413,8 +431,9 @@ static int send_udp_segment(int fd, char *data) > > > =20 > > > static void usage(const char *filepath) > > > { > > > - error(1, 0, "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l sec= s] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]", > > > - filepath); > > > + error(1, 0, > > > + "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] [-L sec= s] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]", > > > + filepath); > >=20 > > Please avoid introducing unnecessary white-space changes (no reason to > > move the usage text on a new line) >=20 > The only reason why I've done this was to make scripts/checkpatch.pl > happy: >=20 > WARNING: line length of 141 exceeds 100 columns > #83: FILE: tools/testing/selftests/net/udpgso_bench_tx.c:432: >=20 > I can drop and ignore the warning, or maybe it would have been better to > just mention this in git message. What do you prefer? Long lines are allowed for (kernel) messages, to make them easily grep- able. In this specific case you can either append the new text to the message without introducing that strange indentation or even better break the usage string alike: "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] [-L secs]" " [-L secs] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]" Cheers, Paolo