selftests: netfilter: nft_concat_range.sh: reduce debug kernel run time
Subsystems (4)
Florian Westphal
maintainerPATCH 1/1 selftests: netfilter: nft_concat_range.sh: reduce debug kernel run time
Even a 1h timeout isn't enough for nft_concat_range.sh to complete on debug kernels.
Reduce test complexity and only match on single entry if KSFT_MACHINE_SLOW is set.
To spot 'slow' tests, print the subtest duration (in seconds) in addition to the status.
Add new nft_concat_range_perf.sh script, not executed via kselftest, to run the performance (pps match rate) tests.
Those need about 25m to complete which seems too much to run this via 'make run_tests'.
--- .../testing/selftests/net/netfilter/Makefile | 2 ++ tools/testing/selftests/net/netfilter/config | 1 + .../net/netfilter/nft_concat_range.sh | 28 +++++++++++++++---- .../net/netfilter/nft_concat_range_perf.sh | 9 ++++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100755 tools/testing/selftests/net/netfilter/nft_concat_range_perf.sh
tools/testing/selftests/net/netfilter/Makefile +2 -0
@@ -28,6 +28,8 @@ TEST_PROGS += nft_zones_many.sh TEST_PROGS += rpath.sh TEST_PROGS += xt_string.sh +TEST_PROGS_EXTENDED = nft_concat_range_perf.sh + TEST_GEN_PROGS = conntrack_dump_flush TEST_GEN_FILES = audit_logread
tools/testing/selftests/net/netfilter/config +1 -0
@@ -85,3 +85,4 @@ CONFIG_VETH=m CONFIG_VLAN_8021Q=m CONFIG_XFRM_USER=m CONFIG_XFRM_STATISTICS=y +CONFIG_NET_PKTGEN=m
tools/testing/selftests/net/netfilter/nft_concat_range.sh +22 -6
@@ -19,7 +19,7 @@ source lib.sh # - timeout: check that packets match entries until they expire # - performance: estimate matching rate, compare with rbtree and hash baselines TESTS="reported_issues correctness concurrency timeout" -[ "${quicktest}" != "1" ] && TESTS="${TESTS} performance" +[ -n "$NFT_CONCAT_RANGE_TESTS" ] && TESTS="${NFT_CONCAT_RANGE_TESTS}" # Set types, defined by TYPE_ variables below TYPES="net_port port_net net6_port port_proto net6_port_mac net6_port_mac_proto
@@ -31,7 +31,7 @@ BUGS="flush_remove_add reload" # List of possible paths to pktgen script from kernel tree for performance tests PKTGEN_SCRIPT_PATHS=" - ../../../../samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh + ../../../../../samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh pktgen/pktgen_bench_xmit_mode_netif_receive.sh" # Definition of set types:
@@ -951,6 +951,10 @@ cleanup() { killall iperf 2>/dev/null killall netperf 2>/dev/null killall netserver 2>/dev/null +} + +cleanup_exit() { + cleanup rm -f "$tmp" }
@@ -1371,6 +1375,9 @@ test_timeout() { setup veth send_"${proto}" set || return ${ksft_skip} timeout=3 + + [ "$KSFT_MACHINE_SLOW" = "yes" ] && timeout=8 + range_size=1 for i in $(seq "$start" $((start + count))); do end=$((start + range_size))
@@ -1386,7 +1393,7 @@ test_timeout() { range_size=$((range_size + 1)) start=$((end + range_size)) done - sleep 3 + sleep $timeout for i in $(seq "$start" $((start + count))); do end=$((start + range_size)) srcstart=$((start + src_delta))
@@ -1480,10 +1487,13 @@ test_performance() { } test_bug_flush_remove_add() { + rounds=100 + [ "$KSFT_MACHINE_SLOW" = "yes" ] && rounds=10 + set_cmd='{ set s { type ipv4_addr . inet_service; flags interval; }; }' elem1='{ 10.0.0.1 . 22-25, 10.0.0.1 . 10-20 }' elem2='{ 10.0.0.1 . 10-20, 10.0.0.1 . 22-25 }' - for i in $(seq 1 100); do + for i in $(seq 1 $rounds); do nft add table t "$set_cmd" || return ${ksft_skip} nft add element t s "$elem1" 2>/dev/null || return 1 nft flush set t s 2>/dev/null || return 1
@@ -1552,7 +1562,7 @@ test_reported_issues() { # Run everything in a separate network namespace [ "${1}" != "run" ] && { unshare -n "${0}" run; exit $?; } tmp="$(mktemp)" -trap cleanup EXIT +trap cleanup_exit EXIT # Entry point for test runs passed=0
@@ -1584,10 +1594,16 @@ for name in ${TESTS}; do continue fi - printf " %-60s " "${display}" + [ "$KSFT_MACHINE_SLOW" = "yes" ] && count=1 + + printf " %-32s " "${display}" + tthen=$(date +%s) eval test_"${name}" ret=$? + tnow=$(date +%s) + printf "%5ds%-30s" $((tnow-tthen)) + if [ $ret -eq 0 ]; then printf "[ OK ]\n" info_flush
tools/testing/selftests/net/netfilter/nft_concat_range_perf.sh new file +9 -0
@@ -0,0 +1,9 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# + +source lib.sh + +[ "$KSFT_MACHINE_SLOW" = yes ] && exit ${ksft_skip} + +NFT_CONCAT_RANGE_TESTS="performance" exec ./nft_concat_range.sh
Signature · 1 line
2.43.2
Simon Horman
reviewerOn Tue, Apr 30, 2024 at 04:58:07PM +0200, Florian Westphal wrote:
...
Quoted 1 line
tools/testing/selftests/net/netfilter/nft_concat_range.sh +0
-0
...
Quoted 5 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +0
-1@@ -1584,10 +1594,16 @@ for name in ${TESTS}; do continue fi - printf " %-60s " "${display}"
tools/testing/selftests/net/netfilter/nft_concat_range.sh for name in ${TESTS}; do · line 1606
Quoted 10 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +7
-0+ [ "$KSFT_MACHINE_SLOW" = "yes" ] && count=1 + + printf " %-32s " "${display}" + tthen=$(date +%s) eval test_"${name}" ret=$? + tnow=$(date +%s) + printf "%5ds%-30s" $((tnow-tthen)) +
Hi Florian,
A minor nit: the format string above expects two variables, but only one is passed.
Flagged by Shellcheck.
Quoted 3 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +0
-0if [ $ret -eq 0 ]; then printf "[ OK ]\n" info_flush
...
Florian Westphal
maintainerQuoted 20 lines · Simon Horman
On Tue, Apr 30, 2024 at 04:58:07PM +0200, Florian Westphal wrote:
...
Quoted 1 line
tools/testing/selftests/net/netfilter/nft_concat_range.sh +0
-0...
Quoted 12 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +4
-1@@ -1584,10 +1594,16 @@ for name in ${TESTS}; do continue fi - printf " %-60s " "${display}" + [ "$KSFT_MACHINE_SLOW" = "yes" ] && count=1 + + printf " %-32s " "${display}" + tthen=$(date +%s) eval test_"${name}" ret=$?
Quoted 8 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh for name in ${TESTS}; do · line 1606
Quoted 3 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +3
-0+ tnow=$(date +%s) + printf "%5ds%-30s" $((tnow-tthen)) +Hi Florian,
A minor nit: the format string above expects two variables, but only one is passed.
Its intentional, I thought this was better than "%5ds "
or similar.
Simon Horman
reviewerQuoted 27 lines · Florian Westphal
Quoted 26 lines · Simon Horman
On Tue, Apr 30, 2024 at 04:58:07PM +0200, Florian Westphal wrote:
...
Quoted 1 line
tools/testing/selftests/net/netfilter/nft_concat_range.sh +0
-0...
Quoted 5 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +0
-1@@ -1584,10 +1594,16 @@ for name in ${TESTS}; do continue fi - printf " %-60s " "${display}"tools/testing/selftests/net/netfilter/nft_concat_range.sh for name in ${TESTS}; do · line 1606
Quoted 10 lines
tools/testing/selftests/net/netfilter/nft_concat_range.sh +7
-0+ [ "$KSFT_MACHINE_SLOW" = "yes" ] && count=1 + + printf " %-32s " "${display}" + tthen=$(date +%s) eval test_"${name}" ret=$? + tnow=$(date +%s) + printf "%5ds%-30s" $((tnow-tthen)) +Hi Florian,
Quoted 5 lines
Quoted 2 lines
A minor nit: the format string above expects two variables, but only one is passed.
Its intentional, I thought this was better than "%5ds "
or similar.
Understood, thanks.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 30 Apr 2024 16:58:07 +0200 you wrote:
Even a 1h timeout isn't enough for
nft_concat_range.shto complete on debug kernels.Reduce test complexity and only match on single entry if
KSFT_MACHINE_SLOWis set.To spot 'slow' tests, print the subtest duration (in seconds) in addition to the status.
[...]
Here is the summary with links:
- [net-next] selftests: netfilter: nft_concat_range.sh: reduce debug kernel run time
https://git.kernel.org/netdev/net-next/c/496bc5861c73
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html