selftests/xsk: improve shared-UMEM coverage - #13385
selftests/xsk: improve shared-UMEM coverage#13385kernel-patches-daemon-bpf[bot] wants to merge 4 commits into
Conversation
|
Upstream branch: aed1bf1 |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 5360031636 via email |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 5360114428 via email |
|
Forwarding comment 5360178594 via email |
5a80da2 to
914a3df
Compare
|
Upstream branch: d19862d |
fae088c to
e6351fd
Compare
914a3df to
c8ffd25
Compare
|
Upstream branch: 4191e49 |
e6351fd to
5e059c0
Compare
c8ffd25 to
6a714eb
Compare
|
Upstream branch: 4954de7 |
5e059c0 to
8d0ad2f
Compare
6a714eb to
27a2ebd
Compare
|
Upstream branch: e40f61a |
8d0ad2f to
381a350
Compare
27a2ebd to
7b6ba88
Compare
|
Upstream branch: 669e4fa |
381a350 to
8cffde0
Compare
7b6ba88 to
d696d45
Compare
|
Upstream branch: a284ed4 |
8cffde0 to
ee8c9a0
Compare
d696d45 to
b8b6131
Compare
|
Upstream branch: 5e289c5 |
ee8c9a0 to
0fd3950
Compare
b8b6131 to
71e031f
Compare
|
Upstream branch: 5e289c5 |
0fd3950 to
dc44f26
Compare
71e031f to
909ca3a
Compare
|
Upstream branch: d83fba2 |
dc44f26 to
a14b740
Compare
909ca3a to
b010507
Compare
|
Upstream branch: ce36e38 |
a14b740 to
21f510d
Compare
b010507 to
975b11a
Compare
|
Upstream branch: 05ea1b6 |
21f510d to
18ed76e
Compare
975b11a to
f8c8078
Compare
UMEM ownership is currently implicit. xsk_configure_umem() maps the buffer, but freeing it is spread across testapp_clean_xsk_umem(), clean_sockets() and clean_umem(), each called from a different error path. thread_common_ops() returns without releasing the UMEM when xsk_configure() fails after the UMEM was already mapped, leaking the mmap()ed buffer. The pthread_barrier_destroy() failure path in __testapp_validate_traffic() unmaps the UMEM owned by ifobj1 while sockets belonging to ifobj2 are left alive. With shared_umem, those sockets reference the buffer that was just unmapped. Make ownership explicit instead. Add a refcount_t users field to struct xsk_umem_info and release exactly one reference per socket on teardown, so that the last socket to go away frees the UMEM regardless of which path tears it down. Keep shared sockets pointing to the same xsk_umem_info instead of copying ownership state, so all users update the same reference count. Propagate UMEM deletion errors from xsk_delete_socket() so callers with stack-allocated state can handle a deferred cleanup before that state goes out of scope. The in-test teardown paths cannot retry, because __test_spec_init() clears the UMEM state at the start of the next test and the mapping is then unrecoverable, so xsk_delete_all_ifobj_sockets() records the failure in test->fail instead of dropping it. A UMEM that survives teardown now fails the test rather than leaking silently. clean_umem() skipped ifobj2 whenever it shared the UMEM owned by ifobj1, which was only there to avoid unmapping the same buffer twice. The reference count makes that distinction unnecessary, so the helper and its special case are removed along with the other ad-hoc cleanup paths. Co-developed-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
|
Upstream branch: 1555de3 |
When RX socket setup fails during the first traffic step, the RX worker reports test->fail only after waiting at the setup barrier. As a result, the main thread may begin TX setup before it detects the failure. In shared-UMEM tests, TX setup relies on the RX-side socket and UMEM state being initialized successfully. Proceeding with TX setup after an RX configuration failure can therefore access uninitialized state. Set test->fail before the RX worker reaches the barrier and verify it before starting the TX thread. The existing teardown path after thread join already handles cleanup of the RX socket slots and UMEM. Co-developed-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
Raise MAX_SOCKETS from 2 to 4 so the XSKMAP and test arrays can accommodate the upcoming 4-socket shared-UMEM test. Update the XSKMAP max_entries to use MAX_SOCKETS so the BPF and C sides stay in sync. Add xsk_xdp_shared_umem_length_based() XDP program that routes packets by total XDP-visible packet length (data_end - data): socket 0 for packets <= SHARED_UMEM_LEN_SPLIT bytes and socket 1 for packets > SHARED_UMEM_LEN_SPLIT bytes. Define SHARED_UMEM_LEN_SPLIT as 64 to avoid hardcoded length thresholds in the classifier. Co-developed-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
Add runner callback infrastructure together with the first four shared-UMEM test cases so each commit in the series builds clean. In __test_spec_init(), shared_default derives shared_umem from TX/RX ifindex equality so resets follow the same baseline behavior used by xskxceiver startup. Add run_shared_umem_test() as the common runner that sets programs/maps, runs the sequence callback, and executes traffic. Declare shared_umem_seq_fn, pkt_stream_dims_fn, shared_umem_len_ctx and shared_umem_uneven_dist_ctx in test_xsk.h, alongside the existing test typedefs and packet stream definitions. Add pkt_stream_replace_seq() to regenerate every per-socket stream from a pkt_stream_dims_fn callback that supplies the packet count and length for a slot. The generated streams are staged in temporary arrays and published into xsk_arr[] only after every allocation has succeeded, so a mid-loop failure frees the new streams and leaves the socket arrays untouched. The streams being replaced are the defaults owned by test_spec and aliased by every slot, so they are not freed on publication. The three sequences differ only in their dims callback: even/odd halving, alternating short/long packet sizes, and a 1:3 packet-volume split across two sockets. Add SHARED_UMEM_4_SOCKETS for a 4-socket even/odd split, SHARED_UMEM_LENGTH_BASED for short-vs-long packet steering, SHARED_UMEM_UNEVEN_DIST for the 1:3 packet-volume distribution, and SHARED_UMEM_UNALIGNED for even/odd sequencing in unaligned mode. The distribution is asserted by the generic per-socket packet accounting in receive_pkts(), which requires nb_rx_pkts to match nb_valid_entries for every socket. Co-developed-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
18ed76e to
5b67a52
Compare
Pull request for series with
subject: selftests/xsk: improve shared-UMEM coverage
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1148173