Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95E92C636D4 for ; Tue, 31 Jan 2023 14:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231812AbjAaOp6 (ORCPT ); Tue, 31 Jan 2023 09:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjAaOp4 (ORCPT ); Tue, 31 Jan 2023 09:45:56 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DAA46727 for ; Tue, 31 Jan 2023 06:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675176312; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xn8TtSD/AsRILC72eNaykv7ZyTuVxpBZIKtdo2DAH1A=; b=gEU/x9Qk0nTqRgCWLGJpREmzt3vmBDMEnqa955ocTkklLDrmHQVZgtiuhoXgWwm+jf5ggH 9obXMuCbS6BWUkw16zk7KZbj500Y9mQBZzjvL1EfqlSXLLw6+pK7diDFOuM1u4GXBNT2OS J4sHUfsDZ0TQkLAKoYfSCsKv3pId4fs= 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_128_GCM_SHA256) id us-mta-385-mrGfdHj0PLqTMJfe87-rJQ-1; Tue, 31 Jan 2023 09:45:10 -0500 X-MC-Unique: mrGfdHj0PLqTMJfe87-rJQ-1 Received: by mail-qk1-f200.google.com with SMTP id h13-20020a05620a244d00b006fb713618b8so9215196qkn.0 for ; Tue, 31 Jan 2023 06:45:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xn8TtSD/AsRILC72eNaykv7ZyTuVxpBZIKtdo2DAH1A=; b=cOE6IrE5onbGHL4Tw13yhZPrxZTrnoq4hwfVgBJszVzrp3b6muGh5qyztCVp76r6rE 4/rJINr0DvRNXhFx4zbupKf8bYnwxeED1Fb/jGiE2yHQ67+Ddf69ws2nAXWr9X/hzddP LYnYQzdqIixKoz6P+WbsxwiMKF0YKSx3dnXKfbfm4/Mwf7CTxGrdqAwzOkRCbsF3kb6H QGlKFf35zckqZUpHKEWH1gJ2bqsIiCFocaWtwyGBJWnmIp9JAoQBy9IzNN87vRU9CLFs 0FLW2MNThe3JLYV3GPaqHPwTSqXbfOiQSHMWLMiH4RV5TRWlDcvmcglg7Z/4lNkHaCs2 Iffw== X-Gm-Message-State: AO0yUKXpCd+8FoyGL5sX/KJDniB1rB8yc9e48tj7SMAz2OoLY6F+Ktxt hyzHYX2Jw1M/smos8jS7lsk8QU0akCunlQ1eqLR+3TKDa+hFqMe4uojpTVLkPEL81Js7j2lvSlu D8+YwV8wXU8d9+qAI8lKHQYD8 X-Received: by 2002:a0c:c484:0:b0:537:7e81:73ec with SMTP id u4-20020a0cc484000000b005377e8173ecmr10038060qvi.3.1675176308467; Tue, 31 Jan 2023 06:45:08 -0800 (PST) X-Google-Smtp-Source: AK7set8/6AUEXMvGYSP/0m29hp2+J2HOrCZjUA3ETettzdz1KyQPZ9G2hmwb7tu/ki9YzwSEWJftrg== X-Received: by 2002:a0c:c484:0:b0:537:7e81:73ec with SMTP id u4-20020a0cc484000000b005377e8173ecmr10038022qvi.3.1675176308174; Tue, 31 Jan 2023 06:45:08 -0800 (PST) Received: from gerbillo.redhat.com (146-241-113-28.dyn.eolo.it. [146.241.113.28]) by smtp.gmail.com with ESMTPSA id o62-20020a37be41000000b006fcaa1eab0esm10147005qkf.123.2023.01.31.06.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 06:45:07 -0800 (PST) Message-ID: Subject: Re: [PATCH v2 3/4] selftests: net: udpgso_bench: Fix racing bug between the rx/tx programs From: Paolo Abeni To: Willem de Bruijn , Andrei Gherzan Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Shuah Khan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 31 Jan 2023 15:45:04 +0100 In-Reply-To: References: <20230131130412.432549-1-andrei.gherzan@canonical.com> <20230131130412.432549-3-andrei.gherzan@canonical.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-01-31 at 08:33 -0500, Willem de Bruijn wrote: > On Tue, Jan 31, 2023 at 8:06 AM Andrei Gherzan > wrote: > >=20 > > "udpgro_bench.sh" invokes udpgso_bench_rx/udpgso_bench_tx programs > > subsequently and while doing so, there is a chance that the rx one is n= ot > > ready to accept socket connections. This racing bug could fail the test > > with at least one of the following: > >=20 > > ./udpgso_bench_tx: connect: Connection refused > > ./udpgso_bench_tx: sendmsg: Connection refused > > ./udpgso_bench_tx: write: Connection refused > >=20 > > This change addresses this by making udpgro_bench.sh wait for the rx > > program to be ready before firing off the tx one - with an exponential = back > > off algorithm from 1s to 10s. > >=20 > > Signed-off-by: Andrei Gherzan >=20 > please CC: reviewers of previous revisions on new revisions >=20 > also for upcoming patches: please clearly mark net or net-next. > > --- > > tools/testing/selftests/net/udpgso_bench.sh | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > >=20 > > diff --git a/tools/testing/selftests/net/udpgso_bench.sh b/tools/testin= g/selftests/net/udpgso_bench.sh > > index dc932fd65363..20b5db8fcbde 100755 > > --- a/tools/testing/selftests/net/udpgso_bench.sh > > +++ b/tools/testing/selftests/net/udpgso_bench.sh > > @@ -7,6 +7,7 @@ readonly GREEN=3D'\033[0;92m' > > readonly YELLOW=3D'\033[0;33m' > > readonly RED=3D'\033[0;31m' > > readonly NC=3D'\033[0m' # No Color > > +readonly TESTPORT=3D8000 # Keep this in sync with udpgso_bench_rx/tx >=20 > then also pass explicit -p argument to the processes to keep all three > consistent >=20 > >=20 > > readonly KSFT_PASS=3D0 > > readonly KSFT_FAIL=3D1 > > @@ -56,10 +57,27 @@ trap wake_children EXIT > >=20 > > run_one() { > > local -r args=3D$@ > > + local -r init_delay_s=3D1 > > + local -r max_delay_s=3D10 > > + local delay_s=3D0 > > + local nr_socks=3D0 > >=20 > > ./udpgso_bench_rx & > > ./udpgso_bench_rx -t & > >=20 > > + # Wait for the above test program to get ready to receive conne= ctions. > > + delay_s=3D"${init_delay_s}" > > + while [ "$delay_s" -lt "$max_delay_s" ]; do > > + nr_socks=3D"$(ss -lnHi | grep -c "\*:${TESTPORT}")" > > + [ "$nr_socks" -eq 2 ] && break > > + sleep "$delay_s" > > + delay=3D"$((delay*2))" >=20 > I don't think we need exponential back-off for something this simple Agreed. Additionally you could use constant, sub-second delay (say 0.1) to keep the runtime delta relatively low. Cheers, Paolo