All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org,
	Konstantin Ananyev <konstantin.ananyev@huawei.com>,
	Marat Khalili <marat.khalili@huawei.com>
Subject: [PATCH 3/6] test: fix race condition in ELF load tests
Date: Sun, 18 Jan 2026 12:09:10 -0800	[thread overview]
Message-ID: <20260118201223.323024-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20260118201223.323024-1-stephen@networkplumber.org>

The BPF ELF tests sporadically fail with EINVAL when loading from
the temporary file. This is a race condition where the BPF loader
reads the file before the data is fully flushed to disk.

Add fsync() before close() in create_temp_bpf_file() to ensure the
BPF object data is visible on the filesystem before attempting to
load it.

Also fix two related issues found during review
- Add missing TEST_ASSERT for mempool creation in test_bpf_elf_tx_load
- Initialize port variable in test_bpf_elf_rx_load to avoid undefined
  behavior in cleanup path if null_vdev_setup fails early

Fixes: cf1e03f881af ("test/bpf: add ELF loading")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_bpf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index a7d56f8d86..03705075d8 100644
--- a/app/test/test_bpf.c
+++ b/app/test/test_bpf.c
@@ -3311,6 +3311,8 @@ create_temp_bpf_file(const uint8_t *data, size_t size, const char *name)
 
 	/* Write BPF object data */
 	written = write(fd, data, size);
+	if (written == (ssize_t)size)
+		fsync(fd);
 	close(fd);
 
 	if (written != (ssize_t)size) {
@@ -3580,6 +3582,7 @@ test_bpf_elf_tx_load(void)
 	mb_pool = rte_pktmbuf_pool_create("bpf_tx_test_pool", BPF_TEST_POOLSIZE,
 					  0, 0, RTE_MBUF_DEFAULT_BUF_SIZE,
 					  SOCKET_ID_ANY);
+	TEST_ASSERT(mb_pool != NULL, "failed to create mempool");
 
 	ret = null_vdev_setup(null_dev, &port, mb_pool);
 	if (ret != 0)
@@ -3664,7 +3667,7 @@ test_bpf_elf_rx_load(void)
 	static const char null_dev[] = "net_null_bpf0";
 	struct rte_mempool *pool = NULL;
 	char *tmpfile = NULL;
-	uint16_t port;
+	uint16_t port = UINT16_MAX;
 	int ret;
 
 	printf("%s start\n", __func__);
-- 
2.51.0


  parent reply	other threads:[~2026-01-18 20:12 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 20:09 [PATCH 0/6] test: fix sporadic failures on high core count systems Stephen Hemminger
2026-01-18 20:09 ` [PATCH 1/6] test: add pause to synchronization spinloops Stephen Hemminger
2026-01-18 20:09 ` [PATCH 2/6] test: fix timeout for atomic test on high core count systems Stephen Hemminger
2026-01-18 20:09 ` Stephen Hemminger [this message]
2026-01-19 11:42   ` [PATCH 3/6] test: fix race condition in ELF load tests Marat Khalili
2026-01-20  0:03     ` Stephen Hemminger
2026-01-20 10:30       ` Marat Khalili
2026-01-19 18:24   ` Stephen Hemminger
2026-01-18 20:09 ` [PATCH 4/6] test: fix unsupported BPF instructions in elf load test Stephen Hemminger
2026-01-19 11:43   ` Marat Khalili
2026-01-18 20:09 ` [PATCH 5/6] test: add file-prefix for all fast-tests on Linux Stephen Hemminger
2026-01-19 13:06   ` Marat Khalili
2026-01-19 14:01     ` Bruce Richardson
2026-01-18 20:09 ` [PATCH 6/6] test: fix trace_autotest_with_traces parallel execution Stephen Hemminger
2026-01-19 13:13   ` Marat Khalili
2026-01-20  0:07     ` Stephen Hemminger
2026-01-20 11:36       ` Marat Khalili
2026-01-22  0:50 ` [PATCH v3 00/14] test: fix test failures on high cores Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 01/14] test: add pause to synchronization spinloops Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 02/14] test: scale atomic test based on core count Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 03/14] test/mcslock: scale test based on number of cores Stephen Hemminger
2026-01-22 10:41     ` Konstantin Ananyev
2026-01-27 20:31       ` Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 04/14] test/stack: " Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 05/14] test/timer: " Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 06/14] test/bpf: fix error handling in ELF load tests Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 07/14] test/bpf: fix unsupported BPF instructions in ELF load test Stephen Hemminger
2026-01-22 10:33     ` Konstantin Ananyev
2026-01-22  0:50   ` [PATCH v3 08/14] test/bpf: skip ELF test if null PMD disabled Stephen Hemminger
2026-01-23 11:56     ` Marat Khalili
2026-01-22  0:50   ` [PATCH v3 09/14] test: add file-prefix for all fast-tests on Linux Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 10/14] test: fix trace_autotest_with_traces parallel execution Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 11/14] test/eventdev: skip test if eventdev driver disabled Stephen Hemminger
2026-01-22 20:40     ` Stephen Hemminger
2026-01-23  9:06       ` Bruce Richardson
2026-01-22  0:50   ` [PATCH v3 12/14] test/pcapng: skip test if null driver missing Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 13/14] test/vdev: skip test if no null PMD Stephen Hemminger
2026-01-22  0:50   ` [PATCH v3 14/14] test/bpf: pass correct size for Rx/Tx load tests Stephen Hemminger
2026-01-23 11:50     ` Marat Khalili
2026-03-05 16:39   ` [PATCH v3 00/14] test: fix test failures on high cores David Marchand
2026-03-05 17:50 ` [PATCH v4 00/11] test: fix test failures on high core count systems Stephen Hemminger
2026-03-05 17:50   ` [PATCH v4 01/11] test: add pause to synchronization spinloops Stephen Hemminger
2026-03-05 17:50   ` [PATCH v4 02/11] test/atomic: scale test based on core count Stephen Hemminger
2026-03-05 17:50   ` [PATCH v4 03/11] test/mcslock: scale test based on number of cores Stephen Hemminger
2026-03-05 17:50   ` [PATCH v4 04/11] test/stack: " Stephen Hemminger
2026-03-05 17:50   ` [PATCH v4 05/11] test/timer: " Stephen Hemminger
2026-03-05 17:51   ` [PATCH v4 06/11] test/timer: replace volatile with C11 atomics Stephen Hemminger
2026-03-05 17:51   ` [PATCH v4 07/11] test: add file-prefix for all fast-tests on Linux Stephen Hemminger
2026-03-05 17:51   ` [PATCH v4 08/11] test: fix trace_autotest_with_traces parallel execution Stephen Hemminger
2026-03-05 17:51   ` [PATCH v4 09/11] test/bpf: fix error handling in ELF load tests Stephen Hemminger
2026-03-05 17:51   ` [PATCH v4 10/11] test/bpf: fix unsupported BPF instructions in ELF load test Stephen Hemminger
2026-03-05 17:51   ` [PATCH v4 11/11] test/bpf: pass correct size for Rx/Tx load tests Stephen Hemminger
2026-03-17 13:28   ` [PATCH v4 00/11] test: fix test failures on high core count systems Thomas Monjalon

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=20260118201223.323024-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=marat.khalili@huawei.com \
    --cc=stable@dpdk.org \
    /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.