Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Lucas Karpinski <lkarpins@redhat.com>,
	 davem@davemloft.net,  edumazet@google.com,  kuba@kernel.org,
	 pabeni@redhat.com,  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 17:11:59 -0400	[thread overview]
Message-ID: <65416d9fc1024_bcdbc29418@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <6ceki76bcv7qz6de5rxc26ot6aezdmeoz2g4ubtve7qwozmyyw@zibbg64wsdjp>

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(-)

The patch subject mentions UDP GSO, but the patch fixes the udpgro
scripts.

There are separate udpgso testcases. So you probably want to s/gso/gro.


> 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
> +	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}" &&

Might a grep be shorter and more readable?

> +			break
> +		sleep 0.1
> +	done
> +}
> +
>  cfg_veth() {
>  	ip netns add "${PEER_NS}"
>  	ip -netns "${PEER_NS}" link set lo up
> @@ -51,8 +67,7 @@ run_one() {
>  		echo "ok" || \
>  		echo "failed" &
>  
> -	# Hack: let bg programs complete the startup
> -	sleep 0.2
> +	wait_local_port_listen 8000
>  	./udpgso_bench_tx ${tx_args}
>  	ret=$?
>  	wait $(jobs -p)
> @@ -97,7 +112,7 @@ run_one_nat() {
>  		echo "ok" || \
>  		echo "failed"&
>  
> -	sleep 0.1
> +	wait_local_port_listen 8000
>  	./udpgso_bench_tx ${tx_args}
>  	ret=$?
>  	kill -INT $pid
> @@ -118,11 +133,9 @@ run_one_2sock() {
>  		echo "ok" || \
>  		echo "failed" &
>  
> -	# Hack: let bg programs complete the startup
> -	sleep 0.2
> +	wait_local_port_listen 12345
>  	./udpgso_bench_tx ${tx_args} -p 12345
> -	sleep 0.1
> -	# first UDP GSO socket should be closed at this point
> +	wait_local_port_listen 8000
>  	./udpgso_bench_tx ${tx_args}
>  	ret=$?
>  	wait $(jobs -p)
> diff --git a/tools/testing/selftests/net/udpgro_bench.sh b/tools/testing/selftests/net/udpgro_bench.sh
> index 894972877e8b..91833518e80b 100755
> --- a/tools/testing/selftests/net/udpgro_bench.sh
> +++ b/tools/testing/selftests/net/udpgro_bench.sh
> @@ -16,6 +16,22 @@ cleanup() {
>  }
>  trap cleanup EXIT
>  
> +wait_local_port_listen()
> +{
> +	local port="${1}"
> +
> +	local port_hex
> +	port_hex="$(printf "%04X" "${port}")"
> +
> +	local i
> +	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
> +}
> +
>  run_one() {
>  	# use 'rx' as separator between sender args and receiver args
>  	local -r all="$@"
> @@ -40,8 +56,7 @@ run_one() {
>  	ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
>  	ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
>  
> -	# Hack: let bg programs complete the startup
> -	sleep 0.2
> +	wait_local_port_listen 8000
>  	./udpgso_bench_tx ${tx_args}
>  }
>  
> diff --git a/tools/testing/selftests/net/udpgro_frglist.sh b/tools/testing/selftests/net/udpgro_frglist.sh
> index 0a6359bed0b9..0aa2068f122c 100755
> --- a/tools/testing/selftests/net/udpgro_frglist.sh
> +++ b/tools/testing/selftests/net/udpgro_frglist.sh
> @@ -16,6 +16,22 @@ cleanup() {
>  }
>  trap cleanup EXIT
>  
> +wait_local_port_listen()
> +{
> +	local port="${1}"
> +
> +	local port_hex
> +	port_hex="$(printf "%04X" "${port}")"
> +
> +	local i
> +	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
> +}
> +
>  run_one() {
>  	# use 'rx' as separator between sender args and receiver args
>  	local -r all="$@"
> @@ -45,8 +61,7 @@ run_one() {
>          echo ${rx_args}
>  	ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
>  
> -	# Hack: let bg programs complete the startup
> -	sleep 0.2
> +	wait_local_port_listen 8000
>  	./udpgso_bench_tx ${tx_args}
>  }
>  
> -- 
> 2.41.0
> 



  parent reply	other threads:[~2023-10-31 21:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30 17:40 [PATCH v2] selftests/net: synchronize udpgso_bench rx and tx Lucas Karpinski
2023-10-31  9:18 ` Paolo Abeni
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 [this message]
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=65416d9fc1024_bcdbc29418@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.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=pabeni@redhat.com \
    --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