From: Paolo Abeni <pabeni@redhat.com>
To: Lucas Karpinski <lkarpins@redhat.com>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
shuah@kernel.org
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] selftests/net: synchronize udpgso_bench rx and tx
Date: Tue, 31 Oct 2023 10:18:28 +0100 [thread overview]
Message-ID: <e8a55d0518da5c1f9aba739359150cad58c03b2b.camel@redhat.com> (raw)
In-Reply-To: <6ceki76bcv7qz6de5rxc26ot6aezdmeoz2g4ubtve7qwozmyyw@zibbg64wsdjp>
On Mon, 2023-10-30 at 13:40 -0400, Lucas Karpinski wrote:
> The sockets used by udpgso_bench_tx aren't always ready when
> udpgso_bench_tx transmits packets. This issue is more prevalent in -rt
> kernels, but can occur in both. Replace the hacky sleep calls with a
> function that checks whether the ports in the namespace are ready for
> use.
>
> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>
> ---
> https://lore.kernel.org/all/t7v6mmuobrbucyfpwqbcujtvpa3wxnsrc36cz5rr6kzzrzkwtj@toz6mr4ggnyp/
>
> Changelog v2:
> - applied synchronization method suggested by Pablo
> - changed commit message to code
>
> tools/testing/selftests/net/udpgro.sh | 27 ++++++++++++++-----
> tools/testing/selftests/net/udpgro_bench.sh | 19 +++++++++++--
> tools/testing/selftests/net/udpgro_frglist.sh | 19 +++++++++++--
> 3 files changed, 54 insertions(+), 11 deletions(-)
>
> diff --git a/tools/testing/selftests/net/udpgro.sh b/tools/testing/selftests/net/udpgro.sh
> index 0c743752669a..04792a315729 100755
> --- a/tools/testing/selftests/net/udpgro.sh
> +++ b/tools/testing/selftests/net/udpgro.sh
> @@ -24,6 +24,22 @@ cleanup() {
> }
> trap cleanup EXIT
>
> +wait_local_port_listen()
> +{
> + local port="${1}"
> +
> + local port_hex
> + port_hex="$(printf "%04X" "${port}")"
> +
> + local i
Minor nit: I think the code would be more readable, if you will group
the variable together:
local port="${1}"
local port_hex
local i
port_hex="$(printf "%04X" "${port}")"
# ...
> + for i in $(seq 10); do
> + ip netns exec "${PEER_NS}" cat /proc/net/udp* | \
> + awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/) {rc=0; exit}} END {exit rc}" &&
> + break
> + sleep 0.1
> + done
> +}
Since you wrote the same function verbatim in 3 different files, I
think it would be better place it in separate, new, net_helper.sh file
and include such file from the various callers. Possibly additionally
rename the function as wait_local_udp_port_listen.
Thanks!
Paolo
next prev parent reply other threads:[~2023-10-31 9:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 17:40 Lucas Karpinski
2023-10-31 9:18 ` Paolo Abeni [this message]
2023-10-31 13:26 ` Lucas Karpinski
2023-10-31 14:49 ` Paolo Abeni
2023-10-31 9:22 ` Paolo Abeni
2023-10-31 21:11 ` Willem de Bruijn
2023-11-01 13:17 ` Lucas Karpinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8a55d0518da5c1f9aba739359150cad58c03b2b.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lkarpins@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®