From patchwork Tue Jan 31 13:04:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrei Gherzan X-Patchwork-Id: 13122972 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 89D28C636CC for ; Tue, 31 Jan 2023 13:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231473AbjAaNF4 (ORCPT ); Tue, 31 Jan 2023 08:05:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjAaNFx (ORCPT ); Tue, 31 Jan 2023 08:05:53 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D784E520 for ; Tue, 31 Jan 2023 05:05:42 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B10C340793 for ; Tue, 31 Jan 2023 13:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675170335; bh=k4C10jaPX9SATgjkcJPgwiqnKoKJu0rj0Lx0+VxMFbA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=OTcC8sDKIc1YQANEGakG5cBF5JY4WsfSv9i8IUGxHIy0lfVk0SlyeZeZpzAVGPs0X HeHJ/5caZyacGyHKJskvVonsGh+1a5K3VUFVrMUpgrGVtcuc55QO7o8G7NoqnI5QO+ Ou0eTl9fc00OZmZRJp+M3Pe47P0pAqS0SKBYnFnpeR4vDYlkY5PLN1OEH8wlYICK0n 9YkeAjQ7nSIwQ3e21yhk/xmM4fJVOtdiB+2rAlBdksYRXd6c1XcneNEt1+Lxb5KvAP XBIzY8ws18NFS76wSE2/6+yeTUZuRJ9ldPlPpfr/ZQkuovdWKtWNigcD0Il/zSDMza TnKrgnDQV0s1g== Received: by mail-wm1-f70.google.com with SMTP id e38-20020a05600c4ba600b003dc434dabbdso6532112wmp.6 for ; Tue, 31 Jan 2023 05:05:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=k4C10jaPX9SATgjkcJPgwiqnKoKJu0rj0Lx0+VxMFbA=; b=0dZq6hsYabajY/qT6pM2WydTsW1V8WFOdGi/LJUrztx9OBrYudgNscIREQQJr26Pro URtKYYdCkPZ0cm2M1v0FUEyTBqb7Sv6gYN2WJQFHHLcfgUYzvVhjvjboHDDDo8oOQWuy 8x6rOnfS/MRLflItl1qj3rxWlZ1vsiY6SueG4xm6LEsrR0T4gdZ++59JHAlY8cddjflv ckSmXwrPK6Dz5RPQxIZIJqPnvkzDhvREB5Q4B4pxg5i+geoypBgArVP2tlh8yvXlUW/E FzaLhkRKr8cgQsklvnsCgvDkQHxJLq/gq02YJqWetrt8SzGwszB9py/TggKG3hw+Eg5R bKqg== X-Gm-Message-State: AO0yUKXSaBWKG3W0lDuT3PsbJhUtOpuWLi228xKQi/RWXtAT8yXRWI3l E5rh6yTf2GlvsWbSplE8gODZ9doRdCbySQEWVN2cDL/DWszYDA+fOn3uHK2Byi9YbglL/lJ8a9U JW4JrH4Q81Oamn3RiWnpdrGeJnz+cwoD2WjO2dEI1NpGTmQ== X-Received: by 2002:adf:c68a:0:b0:2bf:f2f2:7d64 with SMTP id j10-20020adfc68a000000b002bff2f27d64mr5125348wrg.33.1675170335364; Tue, 31 Jan 2023 05:05:35 -0800 (PST) X-Google-Smtp-Source: AK7set/JKOWFouqXY4USuDFfFzUbfIHyMBzspi6+XkMA9ckLWmUhedeQ3yyjl+8b9xB/uwlPFXvVZA== X-Received: by 2002:adf:c68a:0:b0:2bf:f2f2:7d64 with SMTP id j10-20020adfc68a000000b002bff2f27d64mr5125324wrg.33.1675170335068; Tue, 31 Jan 2023 05:05:35 -0800 (PST) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c4dd]) by smtp.gmail.com with ESMTPSA id f6-20020a5d50c6000000b002bfc24e1c55sm14741436wrt.78.2023.01.31.05.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:05:34 -0800 (PST) From: Andrei Gherzan To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Andrei Gherzan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] selftests: net: udpgso_bench_rx: Fix 'used uninitialized' compiler warning Date: Tue, 31 Jan 2023 13:04:09 +0000 Message-Id: <20230131130412.432549-1-andrei.gherzan@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This change fixes the following compiler warning: /usr/include/x86_64-linux-gnu/bits/error.h:40:5: warning: ‘gso_size’ may be used uninitialized [-Wmaybe-uninitialized] 40 | __error_noreturn (__status, __errnum, __format, __va_arg_pack ()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ udpgso_bench_rx.c: In function ‘main’: udpgso_bench_rx.c:253:23: note: ‘gso_size’ was declared here 253 | int ret, len, gso_size, budget = 256; Signed-off-by: Andrei Gherzan --- tools/testing/selftests/net/udpgso_bench_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c index 6a193425c367..d0895bd1933f 100644 --- a/tools/testing/selftests/net/udpgso_bench_rx.c +++ b/tools/testing/selftests/net/udpgso_bench_rx.c @@ -250,7 +250,7 @@ static int recv_msg(int fd, char *buf, int len, int *gso_size) static void do_flush_udp(int fd) { static char rbuf[ETH_MAX_MTU]; - int ret, len, gso_size, budget = 256; + int ret, len, gso_size = 0, budget = 256; len = cfg_read_all ? sizeof(rbuf) : 0; while (budget--) { From patchwork Tue Jan 31 13:04:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Gherzan X-Patchwork-Id: 13122971 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 D0BAEC636D3 for ; Tue, 31 Jan 2023 13:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbjAaNFy (ORCPT ); Tue, 31 Jan 2023 08:05:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjAaNFw (ORCPT ); Tue, 31 Jan 2023 08:05:52 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75030113F3 for ; Tue, 31 Jan 2023 05:05:38 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1C0E541AD2 for ; Tue, 31 Jan 2023 13:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675170337; bh=cknCzfC+eidNxevjQ90DRMfzc86MKFXSFIXJJkqDiTE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j72PpgS8KHiXfMa4PgmXXj6wg3GXgwgWM0KnksLebD0b7uTajB+GD+YbvMyQU01Vg /igt5AcSrvLqKk3otcpnI0e92lr4TMyKgKMWzOU6ddKvFzAEFFdF0hoQEDEGKqu4yF FsrdiiuCDkZ1cCSF//t+hMdIdGIyJBwOSmKQ2vaVwEilsdoPHpePWf7hdqgjmu/C7J LR0UUJRCzEi8jFA/XcAu4vnkfgsItGbNT4m+B6IFF40/55zPOgsGYhZiL4B9o41dXo LAjO+G4ZSlCw7VxLZGnCsKDWq7PiBEIoipFcL2aoHwaDzDeirWLTPOBDt4AP7J/7Ya Sx25bxoBkzm8Q== Received: by mail-wm1-f72.google.com with SMTP id bg25-20020a05600c3c9900b003da1f6a7b2dso11273144wmb.1 for ; Tue, 31 Jan 2023 05:05:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cknCzfC+eidNxevjQ90DRMfzc86MKFXSFIXJJkqDiTE=; b=vvgVKCRNBrmA7mDGvjn07mDaPxiAR7S2fIUDjIitRl/atZKnxfngosEic2RyA4gEaE doCaLIJ5LCRYfmw5hNbD4vl0lDeOn0YbMLwSrzjNf4rYt9GYbo6mAhow630Yo9r8iYUe MZ1mJanRybbHO0XbYQO7WeWqMTUnjYu1O855CuHluaBoup1Vkc+wIyuGvLkmDVon6XJt kHgkfj+/coU3Z+CDRrjttfFO4gAKpGLYujr+Swwj6Az2GXOFmTh3y/ZVaDw/UgdPg+qG rEB0boCLJ9j8ySIABxvkZG3dHKCbx4GLLtXQ3mAdFV0PfJ98xLtxmJZ95RnaTcwZ3U9q ux6g== X-Gm-Message-State: AO0yUKVuLj/wIaNJI0DKrKclqXrXpjpyXeJK615JU44Y8+Q1fiNOsaH8 8ujsHYYDtt9yJhmuDQchyT77OxcsoBqXUu+WncQgb/Z7tzQaKOtjv5416xNsAyxVAaL1FWpv/VZ jktmqHcZi8P1UqJom8gP38wmo0FseyguCL1GuezkeaIcfXg== X-Received: by 2002:a05:6000:69b:b0:2bf:df72:fdfa with SMTP id bo27-20020a056000069b00b002bfdf72fdfamr3214604wrb.40.1675170336517; Tue, 31 Jan 2023 05:05:36 -0800 (PST) X-Google-Smtp-Source: AK7set84uQ9tAkQa/KFTfyH55HgVWiAi7a90Odkg3hQqGTzB5NUa4s4qv0fVF09UC1ty6PxizysYdg== X-Received: by 2002:a05:6000:69b:b0:2bf:df72:fdfa with SMTP id bo27-20020a056000069b00b002bfdf72fdfamr3214581wrb.40.1675170336238; Tue, 31 Jan 2023 05:05:36 -0800 (PST) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c4dd]) by smtp.gmail.com with ESMTPSA id f6-20020a5d50c6000000b002bfc24e1c55sm14741436wrt.78.2023.01.31.05.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:05:35 -0800 (PST) From: Andrei Gherzan To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Andrei Gherzan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] selftests: net: udpgso_bench_rx/tx: Stop when wrong CLI args are provided Date: Tue, 31 Jan 2023 13:04:10 +0000 Message-Id: <20230131130412.432549-2-andrei.gherzan@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131130412.432549-1-andrei.gherzan@canonical.com> References: <20230131130412.432549-1-andrei.gherzan@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Leaving unrecognized arguments buried in the output, can easily hide a CLI/script typo. Avoid this by exiting when wrong arguments are provided to the udpgso_bench test programs. Signed-off-by: Andrei Gherzan --- tools/testing/selftests/net/udpgso_bench_rx.c | 2 ++ tools/testing/selftests/net/udpgso_bench_tx.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c index d0895bd1933f..4058c7451e70 100644 --- a/tools/testing/selftests/net/udpgso_bench_rx.c +++ b/tools/testing/selftests/net/udpgso_bench_rx.c @@ -336,6 +336,8 @@ static void parse_opts(int argc, char **argv) cfg_verify = true; cfg_read_all = true; break; + default: + exit(1); } } diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c index f1fdaa270291..b47b5c32039f 100644 --- a/tools/testing/selftests/net/udpgso_bench_tx.c +++ b/tools/testing/selftests/net/udpgso_bench_tx.c @@ -490,6 +490,8 @@ static void parse_opts(int argc, char **argv) case 'z': cfg_zerocopy = true; break; + default: + exit(1); } } From patchwork Tue Jan 31 13:04:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Gherzan X-Patchwork-Id: 13122974 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 70DCFC636CC for ; Tue, 31 Jan 2023 13:06:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231947AbjAaNGK (ORCPT ); Tue, 31 Jan 2023 08:06:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbjAaNGF (ORCPT ); Tue, 31 Jan 2023 08:06:05 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D864C0F1 for ; Tue, 31 Jan 2023 05:05:51 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 342ED41AD9 for ; Tue, 31 Jan 2023 13:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675170338; bh=mke2sRYMF56da8SzcTS7xCmqUhLspqW5BWedBOJgZhs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VW304v+HiCqyrOiTcTiA/TyipL2yxS7pKZ8uyvbFTlad4ybGW5uB5sxXHCQ3LNqCN Wl1PSzS/Cqycqlg4XlGz7bSxg+gu/A+NpUahTW4DOubkNAxAwiMNDd+D0waY0L2FZo Hjye7JHCssTx4KMAiAtmnYHPS+c5kQaaMClGeW7M1QZXrM10IWa4SsLPCMoOM+C2kl X2gMecn0Uc/eCSHqDSnNACXlSrA54sGpwI8DHetrRDiWMAsEdgnIgOxV1BAW6td03J OX9JHGf0Z/sFMIQGPOa693iAxFdaJrzIrG014L7rWeSoDtKvIJOwpt9cieic0+3uMN /llSZtFnEsa+A== Received: by mail-wm1-f70.google.com with SMTP id l38-20020a05600c1d2600b003ddff4b9a40so71990wms.9 for ; Tue, 31 Jan 2023 05:05:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mke2sRYMF56da8SzcTS7xCmqUhLspqW5BWedBOJgZhs=; b=FzGbtoIfwbKIiaQflDA3q2YVMNLuE4dGYxV8JH/7h7TsWMLHlTg6DSAPJRvH0EGpqI q0ylcy8u1MOr8DqGgePIs5nMZ08rJhpfobMZUYAYt7Mu187enP6YEtUToIylyt4UZCo1 ZG7uXoreVzjilHIi57CuHCTDhEi9IcGmOLLBngbxJZ4rPjIDYycFhNLb0Z2kIVI2AgEy m8Z2fwHNhXLkXLvK13v6++9atYfwT8IX8Xcv+GjfIISezDFwkSCDpCJe5jOH5eqVU9BG N0FDBD2902tc6pi3y1S2Ps3FNl7jVoKY2VXl7dCrcDN5045lqiTEU8khWtPbNxuPHhXh 59Zg== X-Gm-Message-State: AO0yUKUPXNfPNe7TxA/l01edxGGOFlPfmWApLKEg+A2Z3vX49hLfRNZc 8krgkcsGMZfKvcdaTQoO9Nv984RCJkKAMtJES9VSlHfsx+YXlf3Z97yUulbUJezN2j4ZBM4CuWq Knnx3ORHxwFup8MgBlYtvsR2oPCBS8oulxDaEXSY8ddXVzA== X-Received: by 2002:a05:6000:1b89:b0:2bf:d9e3:3e51 with SMTP id r9-20020a0560001b8900b002bfd9e33e51mr2460764wru.56.1675170337778; Tue, 31 Jan 2023 05:05:37 -0800 (PST) X-Google-Smtp-Source: AK7set+XO9fLL7b6ivd1PyynxaJFa6hz5wTD4c9yx9nxWe7sftlJN0awPGBVQ2kLavYQs3KX7JlC3A== X-Received: by 2002:a05:6000:1b89:b0:2bf:d9e3:3e51 with SMTP id r9-20020a0560001b8900b002bfd9e33e51mr2460739wru.56.1675170337473; Tue, 31 Jan 2023 05:05:37 -0800 (PST) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c4dd]) by smtp.gmail.com with ESMTPSA id f6-20020a5d50c6000000b002bfc24e1c55sm14741436wrt.78.2023.01.31.05.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:05:37 -0800 (PST) From: Andrei Gherzan To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Andrei Gherzan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] selftests: net: udpgso_bench: Fix racing bug between the rx/tx programs Date: Tue, 31 Jan 2023 13:04:11 +0000 Message-Id: <20230131130412.432549-3-andrei.gherzan@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131130412.432549-1-andrei.gherzan@canonical.com> References: <20230131130412.432549-1-andrei.gherzan@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org "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 not ready to accept socket connections. This racing bug could fail the test with at least one of the following: ./udpgso_bench_tx: connect: Connection refused ./udpgso_bench_tx: sendmsg: Connection refused ./udpgso_bench_tx: write: Connection refused 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. Signed-off-by: Andrei Gherzan --- tools/testing/selftests/net/udpgso_bench.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/testing/selftests/net/udpgso_bench.sh b/tools/testing/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='\033[0;92m' readonly YELLOW='\033[0;33m' readonly RED='\033[0;31m' readonly NC='\033[0m' # No Color +readonly TESTPORT=8000 # Keep this in sync with udpgso_bench_rx/tx readonly KSFT_PASS=0 readonly KSFT_FAIL=1 @@ -56,10 +57,27 @@ trap wake_children EXIT run_one() { local -r args=$@ + local -r init_delay_s=1 + local -r max_delay_s=10 + local delay_s=0 + local nr_socks=0 ./udpgso_bench_rx & ./udpgso_bench_rx -t & + # Wait for the above test program to get ready to receive connections. + delay_s="${init_delay_s}" + while [ "$delay_s" -lt "$max_delay_s" ]; do + nr_socks="$(ss -lnHi | grep -c "\*:${TESTPORT}")" + [ "$nr_socks" -eq 2 ] && break + sleep "$delay_s" + delay="$((delay*2))" + done + if [ "$nr_socks" -ne 2 ]; then + echo "timed out while waiting for udpgso_bench_rx" + exit 1 + fi + ./udpgso_bench_tx ${args} } From patchwork Tue Jan 31 13:04:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Gherzan X-Patchwork-Id: 13122973 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 F09FAC636D3 for ; Tue, 31 Jan 2023 13:06:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbjAaNGH (ORCPT ); Tue, 31 Jan 2023 08:06:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231996AbjAaNGF (ORCPT ); Tue, 31 Jan 2023 08:06:05 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335B44E52C for ; Tue, 31 Jan 2023 05:05:52 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9D7C441AE3 for ; Tue, 31 Jan 2023 13:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675170340; bh=wLRgJ2g3xT7I9yLnLnLzzOK8LNCx5zIY7gjodxJIDxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E1v4/qO+ZK/5/tDJqgsqidr+PCnHCAbjwKkB04dokudW/JiEfoz6ywP/2CMr7Lxy1 ISSTlIMGcQu2UobgR6UkCV+gAdpytxiKG4Btvs/595W55U7xjcC7xwYpOgfc72Q6WO 3c84fyZF/j5nnsR8jU/ysCu4UH6aiCUZXFjYvRrL/K74U4JvXN1QG0cj3jevRQDE7z VDwFykTGjg5G6+Y+p9d9/ozKA0D0d+QpoLVI+IR7cBL564gEvQNnf18XVK8DzoisIf 8seMZU/aiPSUKlIy0GL07c6oeqYrLFLJkl/AP3pYt8oYgJjMADZWbwFe+XOICkbSWm hKH4zq+fVmATw== Received: by mail-wm1-f72.google.com with SMTP id m10-20020a05600c3b0a00b003dafe7451deso8791187wms.4 for ; Tue, 31 Jan 2023 05:05:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wLRgJ2g3xT7I9yLnLnLzzOK8LNCx5zIY7gjodxJIDxM=; b=l5/N/pqUlBYznHAi/KEzM/gZJQttzkvn6q65SMStY935p9wkllaaSCXzBMQhPK4WJs JX9FcJCFjtgxSGQM5OnBgsoRB8LNHALxWlkxRhKV3HVw/nI981ENzaVhWjuHyucVePvP gTtM5C/yqN9zCEKNCKYsxsaL1hhmJ8myMli2Mz9rFkr4g+clo59BqPDiARM+ciGrNvCh u0pJ4VRo3Be8p3/9ojgGqk5p3jQMrnp1jF/Wn/BUM+QYAaE2oc0gqomd3HS+sgwsjnlM QgdaheqqL4qJ7UzQLELEBkpreWEicdYXUwSdYIUA6p14lTcLIeJmX4KXjvu5ORBXjeTy 8i9A== X-Gm-Message-State: AO0yUKVsJxX6iwvtYjScVLFcaJcWfP80b1tMx/dijMfAmexy/hLDuTUB bD7+8aGGzadViBf8iNefymiU4cRjM18J+d1E8qxcRaO7IjJtHnZUndHGxk5AZmfotwjuDW8PCh7 IwiB8SAHBuuTkI/Jiq7VHJgUW10yhUn1KtTrMXR5NkLpZTA== X-Received: by 2002:a5d:4650:0:b0:2c3:6a8b:2cec with SMTP id j16-20020a5d4650000000b002c36a8b2cecmr112502wrs.60.1675170339384; Tue, 31 Jan 2023 05:05:39 -0800 (PST) X-Google-Smtp-Source: AK7set/akIjMwFjtuH5Lbc7zxow/+PDAFODmUjLu7C6rpySt8f3yNU6mZDxAvz/bS+Ahd90c23ovow== X-Received: by 2002:a5d:4650:0:b0:2c3:6a8b:2cec with SMTP id j16-20020a5d4650000000b002c36a8b2cecmr112452wrs.60.1675170338732; Tue, 31 Jan 2023 05:05:38 -0800 (PST) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c4dd]) by smtp.gmail.com with ESMTPSA id f6-20020a5d50c6000000b002bfc24e1c55sm14741436wrt.78.2023.01.31.05.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:05:38 -0800 (PST) From: Andrei Gherzan To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Andrei Gherzan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] selftests: net: udpgso_bench_tx: Cater for pending datagrams zerocopy benchmarking Date: Tue, 31 Jan 2023 13:04:12 +0000 Message-Id: <20230131130412.432549-4-andrei.gherzan@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131130412.432549-1-andrei.gherzan@canonical.com> References: <20230131130412.432549-1-andrei.gherzan@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The test tool can check that the zerocopy number of completions value is valid taking into consideration the number of datagram send calls. This can catch the system into a state where the datagrams are still in the system (for example in a qdisk, waiting for the network interface to return a completion notification, etc). This change adds a retry logic of computing the number of completions up to a configurable (via CLI) timeout (default: 2 seconds). Signed-off-by: Andrei Gherzan --- tools/testing/selftests/net/udpgso_bench_tx.c | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c index b47b5c32039f..5a29b5f24023 100644 --- a/tools/testing/selftests/net/udpgso_bench_tx.c +++ b/tools/testing/selftests/net/udpgso_bench_tx.c @@ -62,6 +62,7 @@ static int cfg_payload_len = (1472 * 42); static int cfg_port = 8000; static int cfg_runtime_ms = -1; static bool cfg_poll; +static int cfg_poll_loop_timeout_ms = 2000; static bool cfg_segment; static bool cfg_sendmmsg; static bool cfg_tcp; @@ -235,16 +236,17 @@ static void flush_errqueue_recv(int fd) } } -static void flush_errqueue(int fd, const bool do_poll) +static void flush_errqueue(int fd, const bool do_poll, + unsigned long poll_timeout, const bool poll_err) { if (do_poll) { struct pollfd fds = {0}; int ret; fds.fd = fd; - ret = poll(&fds, 1, 500); + ret = poll(&fds, 1, poll_timeout); if (ret == 0) { - if (cfg_verbose) + if ((cfg_verbose) && (poll_err)) fprintf(stderr, "poll timeout\n"); } else if (ret < 0) { error(1, errno, "poll"); @@ -254,6 +256,22 @@ static void flush_errqueue(int fd, const bool do_poll) flush_errqueue_recv(fd); } +static void flush_errqueue_retry(int fd, const bool do_poll, unsigned long num_sends) +{ + unsigned long tnow, tstop; + bool first_try = true; + + tnow = gettimeofday_ms(); + tstop = tnow + cfg_poll_loop_timeout_ms; + do { + flush_errqueue(fd, do_poll, tstop - tnow, first_try); + first_try = false; + if (!do_poll) + usleep(1000); // a throttling delay if polling is enabled + tnow = gettimeofday_ms(); + } while ((stat_zcopies != num_sends) && (tnow < tstop)); +} + static int send_tcp(int fd, char *data) { int ret, done = 0, count = 0; @@ -413,8 +431,9 @@ static int send_udp_segment(int fd, char *data) static void usage(const char *filepath) { - error(1, 0, "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]", - filepath); + error(1, 0, + "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] [-L secs] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]", + filepath); } static void parse_opts(int argc, char **argv) @@ -423,7 +442,7 @@ static void parse_opts(int argc, char **argv) int max_len, hdrlen; int c; - while ((c = getopt(argc, argv, "46acC:D:Hl:mM:p:s:PS:tTuvz")) != -1) { + while ((c = getopt(argc, argv, "46acC:D:Hl:L:mM:p:s:PS:tTuvz")) != -1) { switch (c) { case '4': if (cfg_family != PF_UNSPEC) @@ -452,6 +471,9 @@ static void parse_opts(int argc, char **argv) case 'l': cfg_runtime_ms = strtoul(optarg, NULL, 10) * 1000; break; + case 'L': + cfg_poll_loop_timeout_ms = strtoul(optarg, NULL, 10) * 1000; + break; case 'm': cfg_sendmmsg = true; break; @@ -679,7 +701,7 @@ int main(int argc, char **argv) num_sends += send_udp(fd, buf[i]); num_msgs++; if ((cfg_zerocopy && ((num_msgs & 0xF) == 0)) || cfg_tx_tstamp) - flush_errqueue(fd, cfg_poll); + flush_errqueue(fd, cfg_poll, 500, true); if (cfg_msg_nr && num_msgs >= cfg_msg_nr) break; @@ -698,7 +720,7 @@ int main(int argc, char **argv) } while (!interrupted && (cfg_runtime_ms == -1 || tnow < tstop)); if (cfg_zerocopy || cfg_tx_tstamp) - flush_errqueue(fd, true); + flush_errqueue_retry(fd, true, num_sends); if (close(fd)) error(1, errno, "close");