From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Tushar Vyavahare <tushar.vyavahare@intel.com>
Cc: <netdev@vger.kernel.org>, <magnus.karlsson@intel.com>,
<stfomichev@gmail.com>, <kernelxing@tencent.com>,
<davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<ast@kernel.org>, <daniel@iogearbox.net>,
<tirthendu.sarkar@intel.com>, <bpf@vger.kernel.org>
Subject: Re: [PATCH net-next v2 2/4] selftests/xsk: Move UMEM state from ifobject to xsk_socket_info
Date: Wed, 3 Jun 2026 16:51:59 +0200 [thread overview]
Message-ID: <aiA/j1EWpJgAGIwV@boxer> (raw)
In-Reply-To: <20260603060327.298389-3-tushar.vyavahare@intel.com>
On Wed, Jun 03, 2026 at 11:33:25AM +0530, Tushar Vyavahare wrote:
> Move UMEM ownership from ifobject to xsk_socket_info and access it
> through xsk->umem.
>
> Allocate one shared umem_real in ifobject_create() and let all
> sockets reference it through xsk->umem, while keeping ownership in
> xsk_arr[0]. Keep the existing goto-based error path in
> ifobject_create() and free the allocation once in ifobject_delete().
>
> Reset the existing umem_real in __test_spec_init() with memset()
> instead of reallocating it.
>
> Preserve shared-UMEM behavior by copying RX UMEM state into a TX-local
> UMEM state in thread_common_ops_tx() and reset base_addr/next_buffer
> before TX socket configuration.
>
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
> ---
> .../selftests/bpf/prog_tests/test_xsk.c | 133 +++++++++++-------
> .../selftests/bpf/prog_tests/test_xsk.h | 2 +-
> 2 files changed, 80 insertions(+), 55 deletions(-)
...
> -static void pkt_generate(struct xsk_socket_info *xsk, struct xsk_umem_info *umem, u64 addr, u32 len,
> - u32 pkt_nb, u32 bytes_written)
> +static void pkt_generate(struct xsk_socket_info *xsk, u64 addr, u32 len, u32 pkt_nb,
> + u32 bytes_written)
> {
> - void *data = xsk_umem__get_data(umem->buffer, addr);
> + void *data = xsk_umem__get_data(xsk->umem->buffer, addr);
>
> if (len < MIN_PKT_SIZE)
> return;
> @@ -1003,7 +1010,7 @@ static int __receive_pkts(struct test_spec *test, struct xsk_socket_info *xsk)
> return TEST_FAILURE;
>
> if (!ret) {
> - if (!is_umem_valid(test->ifobj_tx))
> + if (!is_umem_valid(test->ifobj_tx->xsk))
> return TEST_PASS;
>
> ksft_print_msg("ERROR: [%s] Poll timed out\n", __func__);
> @@ -1163,7 +1170,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b
> {
> u32 i, idx = 0, valid_pkts = 0, valid_frags = 0, buffer_len;
> struct pkt_stream *pkt_stream = xsk->pkt_stream;
> - struct xsk_umem_info *umem = ifobject->umem;
> + struct xsk_umem_info *umem = xsk->umem;
> bool use_poll = ifobject->use_poll;
> struct pollfd fds = { };
> int ret;
> @@ -1222,7 +1229,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b
> while (nb_frags_left--) {
> struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx, idx + i);
>
> - tx_desc->addr = pkt_get_addr(pkt, ifobject->umem);
> + tx_desc->addr = pkt_get_addr(pkt, umem);
> if (pkt_stream->verbatim) {
> tx_desc->len = pkt->len;
> tx_desc->options = pkt->options;
> @@ -1234,7 +1241,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b
> tx_desc->options = 0;
> }
> if (pkt->valid)
> - pkt_generate(xsk, umem, tx_desc->addr, tx_desc->len, pkt->pkt_nb,
> + pkt_generate(xsk, tx_desc->addr, tx_desc->len, pkt->pkt_nb,
Nit: you have the umem pointer handy, what's the point to change
pkt_generate() interface?
> bytes_written);
> bytes_written += tx_desc->len;
>
...
> @@ -1856,9 +1875,11 @@ static int testapp_validate_traffic(struct test_spec *test)
> {
> struct ifobject *ifobj_rx = test->ifobj_rx;
> struct ifobject *ifobj_tx = test->ifobj_tx;
> + struct xsk_umem_info *umem_rx = ifobj_rx->xsk->umem;
> + struct xsk_umem_info *umem_tx = ifobj_tx->xsk->umem;
>
> - if ((ifobj_rx->umem->unaligned_mode && !ifobj_rx->unaligned_supp) ||
> - (ifobj_tx->umem->unaligned_mode && !ifobj_tx->unaligned_supp)) {
> + if ((umem_rx->unaligned_mode && !ifobj_rx->unaligned_supp) ||
> + (umem_tx->unaligned_mode && !ifobj_tx->unaligned_supp)) {
> ksft_print_msg("No huge pages present.\n");
> return TEST_SKIP;
> }
this hunk does not add any value IMHO.
next prev parent reply other threads:[~2026-06-03 14:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 6:03 [PATCH net-next v2 0/4] selftests/xsk: simplify UMEM setup Tushar Vyavahare
2026-06-03 6:03 ` [PATCH net-next v2 1/4] selftests/xsk: Introduce helpers for setting UMEM properties Tushar Vyavahare
2026-06-03 14:52 ` Maciej Fijalkowski
2026-06-03 6:03 ` [PATCH net-next v2 2/4] selftests/xsk: Move UMEM state from ifobject to xsk_socket_info Tushar Vyavahare
2026-06-03 14:51 ` Maciej Fijalkowski [this message]
2026-06-04 6:51 ` Vyavahare, Tushar
2026-06-03 6:03 ` [PATCH net-next v2 3/4] selftests/xsk: Use umem_size() helper consistently Tushar Vyavahare
2026-06-03 15:34 ` Maciej Fijalkowski
2026-06-03 6:03 ` [PATCH net-next v2 4/4] selftests/xsk: Introduce mmap_size in umem struct Tushar Vyavahare
2026-06-03 15:35 ` Maciej Fijalkowski
2026-06-04 6:48 ` sashiko-bot
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=aiA/j1EWpJgAGIwV@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stfomichev@gmail.com \
--cc=tirthendu.sarkar@intel.com \
--cc=tushar.vyavahare@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.