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 BB906C54EED for ; Mon, 30 Jan 2023 16:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237523AbjA3QaO (ORCPT ); Mon, 30 Jan 2023 11:30:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237479AbjA3QaL (ORCPT ); Mon, 30 Jan 2023 11:30:11 -0500 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D20E37568 for ; Mon, 30 Jan 2023 08:30:09 -0800 (PST) Received: by mail-yb1-xb2d.google.com with SMTP id m199so14718027ybm.4 for ; Mon, 30 Jan 2023 08:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TPFC8cMkklXYROXSktfu+SUe+7hNbiwoBvUWNNZQCno=; b=DRdqm1G7sz3+3jrt8fpDzB2z7HSSV6gtQFBIYiP27otecjCpAmCJ/txHXrv9KVYa3x qVj0/ioZFHZGG0RhY2RjIU28alJdx8PK+cAYA1NUX2cyWAbaK7ulvOeyxepPdGoeQ82O dRXQmKtn/U1k9bpYrXfzqNOYAV2R6Wb7CPrHLhqEU/pau7bAEhEx0vcfQjLOa8bbe83l LcLbDvELQwmwyhT1qWefL4Ckg+4Y9Eg3x50x6A5AqDYk3uEkwwNxPvIUhQdeGvcWsYHm 5lBZqjmgpLBFt3p0go1gf+N/n4spXoV+piyg05OZslsUTAb1Hu9ExSw4CG4zK+riUDDG w7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TPFC8cMkklXYROXSktfu+SUe+7hNbiwoBvUWNNZQCno=; b=nx+xMF/s7UJ5bGNcATsVcdUTrpRZB7nztN1NkM7omPEISLj1JzcBDDpHT1/ewMF4Ar /SxX1QqH4RqbWQ5NguqZZXH0PFun33SxZ4ozdtvvdLgflMY5wxfHCmTxHpqcB3hTtzQk dZm2dB09OYJjP+t8dOOkgqmo15z9S3QUUHfXqqvKTy8cnBe2vHaiu8d9Cwv7mwDNmsPH x8eOAoe45CVfM7GljQoiAXENrTm7+ofE+I70mJ9d0UoWmSyHJwiw3ivz8UVD6XeihgQ2 3OFEI7ssEi83Q07Jfl1+E31bkoZ2X6IzVm3XCl/q0eFBHzObTzJ0+Yc7nq/RycdzBOU3 pFAg== X-Gm-Message-State: AFqh2krKCoHciyhesSjmUBlBQ3f6+MQNji5CsxsThEaRW6/LeapduYYf xq/Wx+GOQAVvIA1cWkxAUs7a6W/hyvLN/5UPOr/rtA== X-Google-Smtp-Source: AMrXdXtJPRSD2nJpeETSjyTWb9N9nQlXe9LDLFV+Yj2ibrJyK6JgNXl7Kct1hYSFYMK2S6UcEpqYAjYsGida7vX8NDA= X-Received: by 2002:a25:84ce:0:b0:7b7:c7ed:eee9 with SMTP id x14-20020a2584ce000000b007b7c7edeee9mr4700617ybm.334.1675096208397; Mon, 30 Jan 2023 08:30:08 -0800 (PST) MIME-Version: 1.0 References: <20230127181625.286546-1-andrei.gherzan@canonical.com> In-Reply-To: From: Willem de Bruijn Date: Mon, 30 Jan 2023 11:29:31 -0500 Message-ID: Subject: Re: [PATCH] selftests: net: udpgso_bench_tx: Introduce exponential back-off retries To: Andrei Gherzan Cc: Paolo Abeni , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Shuah Khan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 30, 2023 at 11:23 AM Andrei Gherzan wrote: > > On 23/01/30 04:15PM, Andrei Gherzan wrote: > > On 23/01/30 11:03AM, Willem de Bruijn wrote: > > > On Mon, Jan 30, 2023 at 9:28 AM Andrei Gherzan > > > wrote: > > > > > > > > On 23/01/30 08:35AM, Willem de Bruijn wrote: > > > > > On Mon, Jan 30, 2023 at 7:51 AM Andrei Gherzan > > > > > wrote: > > > > > > > > > > > > On 23/01/30 09:26AM, Paolo Abeni wrote: > > > > > > > On Fri, 2023-01-27 at 17:03 -0500, Willem de Bruijn wrote: > > > > > > > > On Fri, Jan 27, 2023 at 1:16 PM Andrei Gherzan > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > The tx and rx test programs are used in a couple of test scripts including > > > > > > > > > "udpgro_bench.sh". Taking this as an example, when the rx/tx programs > > > > > > > > > are invoked subsequently, 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 adding routines that retry the socket > > > > > > > > > operations with an exponential back off algorithm from 100ms to 2s. > > > > > > > > > > > > > > > > > > Fixes: 3a687bef148d ("selftests: udp gso benchmark") > > > > > > > > > Signed-off-by: Andrei Gherzan > > > > > > > > > > > > > > > > Synchronizing the two processes is indeed tricky. > > > > > > > > > > > > > > > > Perhaps more robust is opening an initial TCP connection, with > > > > > > > > SO_RCVTIMEO to bound the waiting time. That covers all tests in one > > > > > > > > go. > > > > > > > > > > > > > > Another option would be waiting for the listener(tcp)/receiver(udp) > > > > > > > socket to show up in 'ss' output before firing-up the client - quite > > > > > > > alike what mptcp self-tests are doing. > > > > > > > > > > > > I like this idea. I have tested it and it works as expected with the > > > > > > exeception of: > > > > > > > > > > > > ./udpgso_bench_tx: sendmsg: No buffer space available > > > > > > > > > > > > Any ideas on how to handle this? I could retry and that works. > > > > > > > > > > This happens (also) without the zerocopy flag, right? That > > > > > > > > > > It might mean reaching the sndbuf limit, which can be adjusted with > > > > > SO_SNDBUF (or SO_SNDBUFFORCE if CAP_NET_ADMIN). Though I would not > > > > > expect this test to bump up against that limit. > > > > > > > > > > A few zerocopy specific reasons are captured in > > > > > https://www.kernel.org/doc/html/latest/networking/msg_zerocopy.html#transmission. > > > > > > > > I have dug a bit more into this, and it does look like your hint was in > > > > the right direction. The fails I'm seeing are only with the zerocopy > > > > flag. > > > > > > > > From the reasons (doc) above I can only assume optmem limit as I've > > > > reproduced it with unlimited locked pages and the fails are transient. > > > > That leaves optmem limit. Bumping the value I have by default (20480) to > > > > (2048000) made the sendmsg succeed as expected. On the other hand, the > > > > tests started to fail with something like: > > > > > > > > ./udpgso_bench_tx: Unexpected number of Zerocopy completions: 774783 > > > > expected 773707 received > > > > > > More zerocopy completions than number of sends. I have not seen this before. > > > > > > The completions are ranges of IDs, one per send call for datagram sockets. > > > > > > Even with segmentation offload, the counter increases per call, not per segment. > > > > > > Do you experience this without any other changes to udpgso_bench_tx.c. > > > Or are there perhaps additional sendmsg calls somewhere (during > > > initial sync) that are not accounted to num_sends? > > > > Indeed, that looks off. No, I have run into this without any changes in > > the tests (besides the retry routine in the shell script that waits for > > rx to come up). Also, as a data point. > > Actually wait. I don't think that is the case here. "expected" is the > number of sends. In this case we sent 1076 more messages than > completions. Am I missing something obvious? Oh indeed. Receiving fewer completions than transmission is more likely. This should be the result of datagrams still being somewhere in the system. In a qdisc, or waiting for the network interface to return a completion notification, say. Does this remain if adding a longer wait before the final flush_errqueue? Or, really, the right fix is to keep polling there until the two are equal, up to some timeout. Currently flush_errqueue calls poll only once. > > > > > As an additional data point, this was only seen on the IPv6 tests. I've > > never been able to replicate it on the IPv4 run. > > I was also fast to send this but it is not correct. I managed to > reproduce it on both IPv4 and IPv6. > > -- > Andrei Gherzan