From patchwork Mon Oct 30 17:40:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Karpinski X-Patchwork-Id: 159834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2387166vqb; Mon, 30 Oct 2023 10:41:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGytkZh2m9bkOYs8Z85i+rUvgmQp0Dq/Dguf3qbhUxherURVRT1P/itgwVPrF7mb4VSBmPq X-Received: by 2002:a17:902:e88e:b0:1ca:3c63:d5cc with SMTP id w14-20020a170902e88e00b001ca3c63d5ccmr9316468plg.49.1698687716447; Mon, 30 Oct 2023 10:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698687716; cv=none; d=google.com; s=arc-20160816; b=e6LE9OsTr6zyNI9Szks5y6orX/sge9agAyBHKlKTg4Tho2fnPaQj6L60MFmLdoe7Jw X2/3t5BZO4MnDU4CJdLPFOAT/zo44UKOeRJn8eNhB0O1t3xBMZJMV5ln+gxkaNtj6x0H h/hoBneJc/8XvZsqbwYvKMYszI8cv4IHtw8PVusiQe0dAoaDuYCxZ7HV59d5e8gutYBD Uo7okxr2EZ3qIs33m2aCJqY5GEMH4WSdfy5bN+FvdRbYtjdbte7IXloY5vAjVo47/0rB fo3y2aJYC4PJpeDYSM3xOru1L8ed5AkRHYQfb9j4dG+YBh+WphqUrht4Xg2x1Ah0t/Mb vOHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=I2JHh73zIxCYXhkBKGYhrEXftWXIPybkxG0xOR3on7I=; fh=qwWQ5TZtzVwhPoNI/LUbvH7isGEdeMFyasRsdv5N8WY=; b=NRKtPhJUT6clpSSmqasWOnxTnW/z2oj/f+Zc1/y+zYfwjbPLfIN6C5emvHlslzk7zy YGgerxDcNSNpn71guiSVL+b+uxdm9D/srghKXcwebfKy8ZGJvaz673LyvNickATix0DD egIhjgKtoC1Oc5mFuuoAPmazgl6U0UI84d7BXfm24mVgkHIefp8YhcBzRJSuaE9hIv/2 MHgHoeYVhl7/J//f5zZFb6ZZc9Bk2mnIjEMsEdTIUHrloI5grXLPbHeCYfhY5IV1jzay CVbBXAAFt34zHR5qRe55fsa9mW70k/9cee7aq/1WR4bl4ArZ0kZpkxbLiwoHwRVPzBQ3 wthQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SrCiRFo0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id ks11-20020a170903084b00b001bbc80a2a3asi5281638plb.299.2023.10.30.10.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 10:41:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SrCiRFo0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B2311804912A; Mon, 30 Oct 2023 10:41:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233946AbjJ3Rlg (ORCPT + 32 others); Mon, 30 Oct 2023 13:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233841AbjJ3Rle (ORCPT ); Mon, 30 Oct 2023 13:41:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50A4E9 for ; Mon, 30 Oct 2023 10:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698687643; 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; bh=I2JHh73zIxCYXhkBKGYhrEXftWXIPybkxG0xOR3on7I=; b=SrCiRFo0pkMu4htZfRcCr6mzMeKLMdv1DNLKfpHzJhWjhe9gISxNZ2YK9G8ln7VvxfH7Jn zzazebc+y1s3m4FTDTPB1tTvRlgXme+p32qCdYJn05e6wRl9XEla4vdv51eEjb+SE1kU9F uL+zdliYJMlCoZVlN9TTClnBlZtzkmY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-_2npL45QM6ijwLWuimCdgA-1; Mon, 30 Oct 2023 13:40:41 -0400 X-MC-Unique: _2npL45QM6ijwLWuimCdgA-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-778a2e847f4so603002185a.0 for ; Mon, 30 Oct 2023 10:40:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698687641; x=1699292441; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I2JHh73zIxCYXhkBKGYhrEXftWXIPybkxG0xOR3on7I=; b=QZUok/gPLYotJd4ELbS5QUCDJI474PM+IW4b0UPRRFMK7AAGWuCCK2bQYW3iIMJ4EM qTIQ7E+4M0Xa5YmQ+S9A1e8dZ58QeFrV9vhDn+G7s1IS8+bZqUTl9h7/ImTuxhI/jQ2v KSZpbIOcpudEKAmJqCUswyV4Xq4waLGuAZggxqtTPS7lbIQrhfrD7eGUs0R5Nxuzm+y7 z8s3ug0GdyPy3veuaJ9P589zwdGKeGpXkpYgZNxEPYGSavLAkmRNBmrg0EtNruMeG2HE uIc8OXweGnSHzoA/Hb5+vIdC1wl1elKFfnoPeXHdbA/6O0FlY/FTV2w+OWI2Qo1H6mTN iQkg== X-Gm-Message-State: AOJu0YznW8aoS8VSehKZUSXahLKK4om4I07XICwuOTUv5a3a3jqOndWm G1rpwF1eWbHwgLxi+mKsJu/QDUgvGKyGtCsAxbboLqkXYVZkn1EeWVwngs+7d8qLrJKyRUMcGrn tRBM4h0tUyLCGsI9B5eXmyzw4 X-Received: by 2002:a05:620a:2589:b0:778:94cc:723 with SMTP id x9-20020a05620a258900b0077894cc0723mr12430101qko.1.1698687641246; Mon, 30 Oct 2023 10:40:41 -0700 (PDT) X-Received: by 2002:a05:620a:2589:b0:778:94cc:723 with SMTP id x9-20020a05620a258900b0077894cc0723mr12430079qko.1.1698687640998; Mon, 30 Oct 2023 10:40:40 -0700 (PDT) Received: from fedora ([142.181.225.135]) by smtp.gmail.com with ESMTPSA id w7-20020a05620a094700b007742c6823a3sm3501927qkw.108.2023.10.30.10.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 10:40:40 -0700 (PDT) Date: Mon, 30 Oct 2023 13:40:39 -0400 From: Lucas Karpinski To: 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: [PATCH v2] selftests/net: synchronize udpgso_bench rx and tx Message-ID: <6ceki76bcv7qz6de5rxc26ot6aezdmeoz2g4ubtve7qwozmyyw@zibbg64wsdjp> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20231006 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 30 Oct 2023 10:41:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781203171189835947 X-GMAIL-MSGID: 1781203171189835947 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 Signed-off-by: Lucas Karpinski --- 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 + 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 +} + 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} }