From: Kal Conley <kal.conley@dectris.com>
To: "Björn Töpel" <bjorn@kernel.org>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Jonathan Lemon" <jonathan.lemon@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Mykola Lysenko" <mykolal@fb.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@google.com>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Shuah Khan" <shuah@kernel.org>
Cc: Kal Conley <kal.conley@dectris.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next v2 07/10] selftests: xsk: Add test UNALIGNED_INV_DESC_4K1_FRAME_SIZE
Date: Wed, 29 Mar 2023 20:04:59 +0200 [thread overview]
Message-ID: <20230329180502.1884307-8-kal.conley@dectris.com> (raw)
In-Reply-To: <20230329180502.1884307-1-kal.conley@dectris.com>
Add unaligned descriptor test for frame size of 4001. Using an odd frame
size ensures that the end of the UMEM is not near a page boundary. This
allows testing descriptors that staddle the end of the UMEM but not a
page.
This test used to fail without the previous commit ("xsk: Add check for
unaligned descriptors that overrun UMEM").
Signed-off-by: Kal Conley <kal.conley@dectris.com>
---
tools/testing/selftests/bpf/xskxceiver.c | 25 ++++++++++++++++++++++++
tools/testing/selftests/bpf/xskxceiver.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index 1a4bdd5aa78c..9b9efd0e0a4c 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -69,6 +69,7 @@
*/
#define _GNU_SOURCE
+#include <assert.h>
#include <fcntl.h>
#include <errno.h>
#include <getopt.h>
@@ -1876,6 +1877,30 @@ static void run_pkt_test(struct test_spec *test, enum test_mode mode, enum test_
test->ifobj_rx->umem->unaligned_mode = true;
testapp_invalid_desc(test);
break;
+ case TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME:
+ if (!hugepages_present(test->ifobj_tx)) {
+ ksft_test_result_skip("No 2M huge pages present.\n");
+ return;
+ }
+ test_spec_set_name(test, "UNALIGNED_INV_DESC_4K1_FRAME_SIZE");
+ /* Odd frame size so the UMEM doesn't end near a page boundary. */
+ test->ifobj_tx->umem->frame_size = 4001;
+ test->ifobj_rx->umem->frame_size = 4001;
+ test->ifobj_tx->umem->unaligned_mode = true;
+ test->ifobj_rx->umem->unaligned_mode = true;
+ /* This test exists to test descriptors that staddle the end of
+ * the UMEM but not a page.
+ */
+ {
+ u64 umem_size = test->ifobj_tx->umem->num_frames *
+ test->ifobj_tx->umem->frame_size;
+ u64 page_size = sysconf(_SC_PAGESIZE);
+
+ assert(umem_size % page_size > PKT_SIZE);
+ assert(umem_size % page_size < page_size - PKT_SIZE);
+ }
+ testapp_invalid_desc(test);
+ break;
case TEST_TYPE_UNALIGNED:
if (!testapp_unaligned(test))
return;
diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h
index cc24ab72f3ff..919327807a4e 100644
--- a/tools/testing/selftests/bpf/xskxceiver.h
+++ b/tools/testing/selftests/bpf/xskxceiver.h
@@ -78,6 +78,7 @@ enum test_type {
TEST_TYPE_ALIGNED_INV_DESC,
TEST_TYPE_ALIGNED_INV_DESC_2K_FRAME,
TEST_TYPE_UNALIGNED_INV_DESC,
+ TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME,
TEST_TYPE_HEADROOM,
TEST_TYPE_TEARDOWN,
TEST_TYPE_BIDI,
--
2.39.2
next prev parent reply other threads:[~2023-03-29 18:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 18:04 [PATCH bpf-next v2 00/10] xsk: Support UMEM chunk_size > PAGE_SIZE Kal Conley
2023-03-29 18:04 ` [PATCH bpf-next v2 01/10] selftests: xsk: Add xskxceiver.h dependency to Makefile Kal Conley
2023-03-29 18:04 ` [PATCH bpf-next v2 02/10] selftests: xsk: Use correct UMEM size in testapp_invalid_desc Kal Conley
2023-03-29 18:04 ` [PATCH bpf-next v2 03/10] selftests: xsk: Add test case for packets at end of UMEM Kal Conley
2023-03-29 18:04 ` [PATCH bpf-next v2 04/10] selftests: xsk: Deflakify STATS_RX_DROPPED test Kal Conley
2023-04-03 10:54 ` Magnus Karlsson
2023-04-03 11:06 ` Kal Cutter Conley
2023-04-03 11:40 ` Kal Cutter Conley
2023-04-03 11:38 ` Magnus Karlsson
2023-04-03 11:47 ` Kal Cutter Conley
2023-03-29 18:04 ` [PATCH bpf-next v2 05/10] selftests: xsk: Disable IPv6 on VETH1 Kal Conley
2023-03-29 18:04 ` [PATCH bpf-next v2 06/10] xsk: Add check for unaligned descriptors that overrun UMEM Kal Conley
2023-04-03 12:23 ` Magnus Karlsson
2023-04-03 12:50 ` Kal Cutter Conley
2023-03-29 18:04 ` Kal Conley [this message]
2023-04-03 12:25 ` [PATCH bpf-next v2 07/10] selftests: xsk: Add test UNALIGNED_INV_DESC_4K1_FRAME_SIZE Magnus Karlsson
2023-03-29 18:05 ` [PATCH bpf-next v2 08/10] xsk: Support UMEM chunk_size > PAGE_SIZE Kal Conley
2023-04-04 7:39 ` Magnus Karlsson
2023-04-04 8:20 ` Kal Cutter Conley
2023-04-04 9:29 ` Magnus Karlsson
2023-04-04 10:33 ` Kal Cutter Conley
2023-04-04 11:14 ` Magnus Karlsson
2023-04-04 12:18 ` Kal Cutter Conley
2023-04-04 12:37 ` Kal Cutter Conley
2023-04-04 12:54 ` Magnus Karlsson
2023-03-29 18:05 ` [PATCH bpf-next v2 09/10] selftests: xsk: Use hugepages when umem->frame_size " Kal Conley
2023-03-29 18:05 ` [PATCH bpf-next v2 10/10] selftests: xsk: Add tests for 8K and 9K frame sizes Kal Conley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230329180502.1884307-8-kal.conley@dectris.com \
--to=kal.conley@dectris.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jonathan.lemon@gmail.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).