From patchwork Mon Apr 3 12:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kal Cutter Conley X-Patchwork-Id: 13198108 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 56BF1C77B62 for ; Mon, 3 Apr 2023 12:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232261AbjDCMEV (ORCPT ); Mon, 3 Apr 2023 08:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbjDCMEQ (ORCPT ); Mon, 3 Apr 2023 08:04:16 -0400 Received: from mail-ed1-x564.google.com (mail-ed1-x564.google.com [IPv6:2a00:1450:4864:20::564]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A636B59F1 for ; Mon, 3 Apr 2023 05:04:09 -0700 (PDT) Received: by mail-ed1-x564.google.com with SMTP id er13so75353912edb.9 for ; Mon, 03 Apr 2023 05:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dectris.com; s=google; t=1680523448; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Mv9eSPw2NYDm+zLdn/0KIdtGuLd5MVBc/kA1IEA/9U8=; b=qeLcnaJvpGzxzC9i2/5UzqXUn0aCH0vyWkKClH/xO2mw5d0sxsfOU84hGlNAlIyj3T HM5N0+wtUwVioRD56uqOqHHmo+V2eV35THsxuTTiMOn0pLREW5D21VnQ7UXTW/RlSEm0 achUFDrhpgjMzG1xbdweAPoGwdzCbh75n2gi0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680523448; 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=Mv9eSPw2NYDm+zLdn/0KIdtGuLd5MVBc/kA1IEA/9U8=; b=27IEhcy3Yrbpm3C4NZsA/w8UK+vRYOxfJ8ADEVsN4I9nZkfOWy8bigP9qmHohBqDLV Be8LUYhKEtmGnioEx0RfieNSOei5RyurTEW7BAstEkWG65YnnQB75LIuoTdyiXknAHGt rliEHK4pSjD6OEUoHT7ctkXJ/hTuD+rrFJIhrco1Umtt63afGZBL+cTVLbZae2uGaup5 6D5VOXg7TFYQxJ16DvQEZP86XTtWeW1Lb19bMLv6r+1U8rS2ibW5qPzzlAIMaCqcHvrM 4LkRv/gpq4DBR6vxoofurS+XEm3iUsEg/v3vCUWHoYh2aA86YBY5c7DjFGlQriRoUoGS HNxw== X-Gm-Message-State: AAQBX9d2x7cFq3iYFeLiebLYoFCJCAIqZIIEZhDzxqjQoUcB/TdhFbez CAG2hIyZZ3QdxI6Qz6x8xMUzXBPQWeHGBxV2gJknihtLwoZB X-Google-Smtp-Source: AKy350bUU6hMTd1TMujkpxpKhnxiqLj2cfko1OJLyNg9wh5tN+dyqD8vkd+4SwQbNePb4gRX6VT7DZ+TD912 X-Received: by 2002:a17:907:a0b:b0:93e:739f:b0b3 with SMTP id bb11-20020a1709070a0b00b0093e739fb0b3mr46736265ejc.50.1680523448055; Mon, 03 Apr 2023 05:04:08 -0700 (PDT) Received: from fedora.dectris.local (dect-ch-bad-pfw.cyberlink.ch. [62.12.151.50]) by smtp-relay.gmail.com with ESMTPS id g26-20020a17090613da00b0093d0d964affsm3174279ejc.73.2023.04.03.05.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 05:04:08 -0700 (PDT) X-Relaying-Domain: dectris.com From: Kal Conley To: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: Kal Conley , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf] selftests: xsk: Deflakify STATS_RX_DROPPED test Date: Mon, 3 Apr 2023 14:03:59 +0200 Message-Id: <20230403120400.31018-1-kal.conley@dectris.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Fix flaky STATS_RX_DROPPED test. The receiver calls getsockopt after receiving the last (valid) packet which is not the final packet sent in the test (valid and invalid packets are sent in alternating fashion with the final packet being invalid). Since the last packet may or may not have been dropped already, both outcomes must be allowed. This issue could also be fixed by making sure the last packet sent is valid. This alternative is left as an exercise to the reader (or the benevolent maintainers of this file). This problem was quite visible on certain setups. On one machine this failure was observed 50% of the time. Also, remove a redundant assignment of pkt_stream->nb_pkts. This field is already initialized by __pkt_stream_alloc. Fixes: 27e934bec35b ("selftests: xsk: make stat tests not spin on getsockopt") Signed-off-by: Kal Conley Acked-by: Magnus Karlsson --- tools/testing/selftests/bpf/xskxceiver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index a17655107a94..30a364283542 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -631,7 +631,6 @@ static struct pkt_stream *pkt_stream_generate(struct xsk_umem_info *umem, u32 nb if (!pkt_stream) exit_with_error(ENOMEM); - pkt_stream->nb_pkts = nb_pkts; for (i = 0; i < nb_pkts; i++) { pkt_set(umem, &pkt_stream->pkts[i], (i % umem->num_frames) * umem->frame_size, pkt_len); @@ -1124,7 +1123,14 @@ static int validate_rx_dropped(struct ifobject *ifobject) if (err) return TEST_FAILURE; - if (stats.rx_dropped == ifobject->pkt_stream->nb_pkts / 2) + /* The receiver calls getsockopt after receiving the last (valid) + * packet which is not the final packet sent in this test (valid and + * invalid packets are sent in alternating fashion with the final + * packet being invalid). Since the last packet may or may not have + * been dropped already, both outcomes must be allowed. + */ + if (stats.rx_dropped == ifobject->pkt_stream->nb_pkts / 2 || + stats.rx_dropped == ifobject->pkt_stream->nb_pkts / 2 - 1) return TEST_PASS; return TEST_FAILURE;