Improve stability of big_tcp_tunnels.sh selftest
Subsystems (3)
cover Improve stability of big_tcp_tunnels.sh selftest
From: Alice Mikityanska <[email protected]>
This series addresses flakiness of big_tcp_tunnels.sh discussed at:
https://lore.kernel.org/netdev/[email protected]/
Lower the thresholds to avoid failures like this (number of packets below the threshold):
Tweak tcp_min_tso_segs and initcwnd to avoid failures like this (BIG TCP doesn't kick in in slow configurations):
Alice Mikityanska (4):
selftests: net: Wait for netserver to launch
selftests: net: Lower threshold on debug kernels for
big_tcp_tunnels.sh
selftests: net: Lower threshold with csum offload off in
big_tcp_tunnels.sh
selftests: net: Fix slow configurations in big_tcp_tunnels.sh
.../testing/selftests/net/big_tcp_tunnels.sh | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/4 selftests: net: Wait for netserver to launch
From: Alice Mikityanska <[email protected]>
Use wait_local_port_listen after starting netserver in big_tcp_tunnels.sh to ensure it's listening when the test starts.
--- tools/testing/selftests/net/big_tcp_tunnels.sh | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/selftests/net/big_tcp_tunnels.sh +3 -0
@@ -3,6 +3,8 @@ # # Testing for IPv4 and IPv6 BIG TCP over VXLAN and GENEVE tunnels. +source "$(dirname "$0")/lib.sh" + SERVER_NS=$(mktemp -u server-XXXXXXXX) SERVER_IP4="192.168.1.1" SERVER_IP6="2001:db8::1:1"
@@ -39,6 +41,7 @@ setup() { gro_max_size 196608 gro_ipv4_max_size 196608 ip netns exec "$SERVER_NS" netserver >/dev/null + wait_local_port_listen "$SERVER_NS" 12865 tcp } setup_tunnel() {
Signature · 1 line
2.55.0
PATCH 2/4 selftests: net: Lower threshold on debug kernels for big_tcp_tunnels.sh
In reply to Alice MikityanskaFrom: Alice Mikityanska <[email protected]>
CONFIG_DEBUG_NET kernels run slower and generate fewer BIG TCP packets, making the test flaky on upstream CI runners. Lower the default threshold for those kernels.
--- tools/testing/selftests/net/big_tcp_tunnels.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
tools/testing/selftests/net/big_tcp_tunnels.sh +16 -2
@@ -17,11 +17,25 @@ CLIENT_IP6="2001:db8::1:2" CLIENT_IP4_TUN="192.168.2.2" CLIENT_IP6_TUN="2001:db8::2:2" -: "${PACKETS_THRESHOLD:=1000}" - # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +is_debug() { + local config="/proc/config.gz" + [ -f "$config" ] || config="/boot/config-$(uname -r)" + [ -f "$config" ] || return 1 # No config found; assume non-debug. + gzip -dcfq "$config" | grep -qx 'CONFIG_DEBUG_NET=y' || return 1 +} + +if [ -z "$PACKETS_THRESHOLD" ]; then + if is_debug; then + echo 'Debug kernel detected, lowering the default threshold' + PACKETS_THRESHOLD=100 + else + PACKETS_THRESHOLD=1000 + fi +fi + setup() { ip netns add "$SERVER_NS" ip netns add "$CLIENT_NS"
Signature · 1 line
2.55.0
PATCH 3/4 selftests: net: Lower threshold with csum offload off in big_tcp_tunnels.sh
In reply to Alice MikityanskaFrom: Alice Mikityanska <[email protected]>
With checksum offload disabled, much fewer BIG TCP packets are generated due to overall loss of throughput. Use a separate threshold in these tests, which is 1/10 of the threshold set for the rest of tests.
--- tools/testing/selftests/net/big_tcp_tunnels.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/net/big_tcp_tunnels.sh +5 -2
@@ -114,6 +114,8 @@ cleanup() { } do_test() { + local packets_threshold="$PACKETS_THRESHOLD" + # When tx csum offload is off, software GSO is performed before passing the # packet to veth. Check BIG TCP packets inside the VXLAN tunnel to verify # the software checksum path: if the checksum code is broken, these packets
@@ -132,6 +134,7 @@ do_test() { else IPTABLES=ip6tables fi + packets_threshold=$(( PACKETS_THRESHOLD / 10 )) fi if [ "$2" = 4 ]; then IPTABLES_SACK=iptables
@@ -164,8 +167,8 @@ do_test() { echo "Captured BIG TCP RX packets: $PACKETS_SERVER" echo "Captured BIG TCP TX packets: $PACKETS_CLIENT" echo "Captured TCP SACK packets: $PACKETS_SACK" - [ "$PACKETS_SERVER" -gt "$PACKETS_THRESHOLD" ] || return 1 - [ "$PACKETS_CLIENT" -gt "$PACKETS_THRESHOLD" ] || return 1 + [ "$PACKETS_SERVER" -gt "$packets_threshold" ] || return 1 + [ "$PACKETS_CLIENT" -gt "$packets_threshold" ] || return 1 [ "$PACKETS_SACK" -lt "$(( PACKETS_CLIENT / 2 ))" ] || return 1 }
Signature · 1 line
2.55.0
PATCH 4/4 selftests: net: Fix slow configurations in big_tcp_tunnels.sh
In reply to Alice MikityanskaFrom: Alice Mikityanska <[email protected]>
The combination of checksum offload disabled (that causes software GSO) and CONFIG_DEBUG_NET=y is inherently slow. Depending on the CPU power and load, RTT may increase, limiting sk_pacing_rate, so tcp_tso_autosize caps SKBs at around 40 segments, and zero BIG TCP packets are produced.
Increase sysctl net.ipv4.tcp_min_tso_segs and set a bigger initial value of CWND in these configurations to force BIG TCP.
--- tools/testing/selftests/net/big_tcp_tunnels.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
tools/testing/selftests/net/big_tcp_tunnels.sh +17 -0
@@ -56,6 +56,8 @@ setup() { ip netns exec "$SERVER_NS" netserver >/dev/null wait_local_port_listen "$SERVER_NS" 12865 tcp + + DEFAULT_TCP_MIN_TSO_SEGS=$(ip netns exec "$CLIENT_NS" sysctl -n net.ipv4.tcp_min_tso_segs) } setup_tunnel() {
@@ -142,6 +144,21 @@ do_test() { IPTABLES_SACK=ip6tables fi + if [ "$3" != 'on' ] && is_debug; then + echo 'Slow configuration; increasing net.ipv4.tcp_min_tso_segs and initcwnd' + ip netns exec "$CLIENT_NS" sysctl -w net.ipv4.tcp_min_tso_segs=52 + if [ "$2" = 4 ]; then + ip -netns "$CLIENT_NS" \ + route change 192.168.2.0/24 dev tun0 initcwnd 100 + else + ip -netns "$CLIENT_NS" -6 \ + route change 2001:db8::2:0/112 dev tun0 initcwnd 100 + fi + else + ip netns exec "$CLIENT_NS" \ + sysctl -w net.ipv4.tcp_min_tso_segs="$DEFAULT_TCP_MIN_TSO_SEGS" + fi + ip netns exec "$SERVER_NS" "$IPTABLES" -w -t raw -I PREROUTING -i "${CAPTURE_IFACE}1" -m length ! --length 0:65535 -m comment --comment "bigtcp" ip netns exec "$CLIENT_NS" "$IPTABLES" -w -t raw -I OUTPUT -o "${CAPTURE_IFACE}0" -m length ! --length 0:65535 -m comment --comment "bigtcp" ip netns exec "$SERVER_NS" "$IPTABLES_SACK" -w -t raw -I OUTPUT -o "tun1" -p tcp -m tcp --tcp-flags ACK ACK --tcp-option 5 -m comment --comment "sack"
Signature · 1 line
2.55.0
Re: [PATCH net-next 2/4] selftests: net: Lower threshold on debug kernels for big_tcp_tunnels.sh
In reply to Alice MikityanskaHi Alice,
Quoted 5 lines · Alice Mikityanska
From: Alice Mikityanska <[email protected]>
CONFIG_DEBUG_NETkernels run slower and generate fewer BIG TCP packets, making the test flaky on upstream CI runners. Lower the default threshold for those kernels.
Thank you for looking at that!
Quoted 13 lines
Signed-off-by Alice Mikityanska <[email protected]>--- tools/testing/selftests/net/big_tcp_tunnels.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)tools/testing/selftests/net/big_tcp_tunnels.sh +0
-0@@ -17,11 +17,25 @@ CLIENT_IP6="2001:db8::1:2" CLIENT_IP4_TUN="192.168.2.2" CLIENT_IP6_TUN="2001:db8::2:2"
tools/testing/selftests/net/big_tcp_tunnels.sh CLIENT_IP6="2001:db8::1:2" · line 27
Quoted 10 lines
tools/testing/selftests/net/big_tcp_tunnels.sh +5
-2-: "${PACKETS_THRESHOLD:=1000}" - # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +is_debug() { + local config="/proc/config.gz" + [ -f "$config" ] || config="/boot/config-$(uname -r)" + [ -f "$config" ] || return 1 # No config found; assume non-debug. + gzip -dcfq "$config" | grep -qx 'CONFIG_DEBUG_NET=y' || return 1
Are you sure it is CONFIG_DEBUG_NET that causes that? It shouldn't be that heavy.
Do you not want to change the thresholds only for the -dbg runners using kernel/configs/debug.config? If yes, you should check if KSFT_MACHINE_SLOW == yes:
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Re: [PATCH net-next 4/4] selftests: net: Fix slow configurations in big_tcp_tunnels.sh
In reply to Alice MikityanskaHi Alice,
Quoted 9 lines · Alice Mikityanska
From: Alice Mikityanska <[email protected]>
The combination of checksum offload disabled (that causes software GSO) and
CONFIG_DEBUG_NET=yis inherently slow. Depending on the CPU power and load, RTT may increase, limitingsk_pacing_rate, sotcp_tso_autosizecaps SKBs at around 40 segments, and zero BIG TCP packets are produced.Increase sysctl net.ipv4.tcp_min_tso_segs and set a bigger initial value of CWND in these configurations to force BIG TCP.
Just an innocent question: would it affect the test somehow if the sysctl and initial cwnd is always modified, not just for a specific config?
(Note that apart from looking at ${KSFT_MACHINE_SLOW} in patch 2, I think the series looks good to me, and can probably be sent to net after the merge with net-next.)
Cheers,
Matt
Re: [PATCH net-next 2/4] selftests: net: Lower threshold on debug kernels for big_tcp_tunnels.sh
In reply to Matthieu BaertsQuoted 38 lines · Matthieu Baerts
Hi Alice,
Quoted 5 lines · Alice Mikityanska
From: Alice Mikityanska <[email protected]>
CONFIG_DEBUG_NETkernels run slower and generate fewer BIG TCP packets, making the test flaky on upstream CI runners. Lower the default threshold for those kernels.Thank you for looking at that!
Quoted 13 lines
Signed-off-by Alice Mikityanska <[email protected]>--- tools/testing/selftests/net/big_tcp_tunnels.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)tools/testing/selftests/net/big_tcp_tunnels.sh +0
-0@@ -17,11 +17,25 @@ CLIENT_IP6="2001:db8::1:2" CLIENT_IP4_TUN="192.168.2.2" CLIENT_IP6_TUN="2001:db8::2:2"tools/testing/selftests/net/big_tcp_tunnels.sh CLIENT_IP6="2001:db8::1:2" · line 27
Quoted 10 lines
tools/testing/selftests/net/big_tcp_tunnels.sh +5
-2-: "${PACKETS_THRESHOLD:=1000}" - # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +is_debug() { + local config="/proc/config.gz" + [ -f "$config" ] || config="/boot/config-$(uname -r)" + [ -f "$config" ] || return 1 # No config found; assume non-debug. + gzip -dcfq "$config" | grep -qx 'CONFIG_DEBUG_NET=y' || return 1Are you sure it is
CONFIG_DEBUG_NETthat causes that? It shouldn't be that heavy.
Quoted 3 lines
Do you not want to change the thresholds only for the -dbg runners using
kernel/configs/debug.config? If yes, you should check ifKSFT_MACHINE_SLOW== yes:
Thanks for the suggestion! I'll switch to KSFT_MACHINE_SLOW.
Quoted 6 lines
Cheers,
MattSignature · 1 line
Sponsored by the NGI0 Core fund.
Re: [PATCH net-next 4/4] selftests: net: Fix slow configurations in big_tcp_tunnels.sh
In reply to Matthieu BaertsQuoted 10 lines · Matthieu Baerts
Hi Alice,
Quoted 7 lines · Alice Mikityanska
From: Alice Mikityanska <[email protected]>
The combination of checksum offload disabled (that causes software GSO) and
CONFIG_DEBUG_NET=yis inherently slow. Depending on the CPU power and load, RTT may increase, limitingsk_pacing_rate, sotcp_tso_autosizecaps SKBs at around 40 segments, and zero BIG TCP packets are produced.
Quoted 4 lines
Quoted 2 lines
Increase sysctl net.ipv4.tcp_min_tso_segs and set a bigger initial value of CWND in these configurations to force BIG TCP.
Just an innocent question: would it affect the test somehow if the sysctl and initial cwnd is always modified, not just for a specific config?
That would guarantee that BIG TCP kicks in, but IMO it reduces the coverage by not letting BIG TCP kick in naturally. I'd keep the defaults in fast tests.
Quoted 3 lines
(Note that apart from looking at ${KSFT_MACHINE_SLOW} in patch 2, I think the series looks good to me, and can probably be sent to net after the merge with net-next.)
Thanks! I'll wait for the selftest to be merged to net and send the follow- ups there.
Quoted 2 lines
Cheers,
Matt