Skip to contentSkip to conversation

io_uring: Add test for READV and WRITEV operations

PATCH Superseded Sachin Sant 2 participants 2 messages Apr 16

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 io_uring: Add test for READV and WRITEV operations

Add a test to validate vectored read and write operations using io_uring.

1. IORING_OP_WRITEV - Writing data using multiple buffers (scatter)
2. IORING_OP_READV - Reading data into multiple buffers (gather)
3. Data integrity verification across multiple iovecs
4. Edge cases with different iovec configurations including zero buffer length

Additionally merge io_uring_init_buffer_pattern() into unified init_iovec_buffers() function that supports both rotating and simple character patterns

---
V4 changes:
- Updated commit message to remove references to non-existent function
- Removed extra blank line before test_writev_readv()
- Link to v3 https://lore.kernel.org/ltp/[email protected]/T/

V3 changes (2/3 io_uring04 only):
- 1/3 and 3/3 from the patch series already merged.
- Merged prepare_read_buffers() and clear_iovec_buffers() into
single clear_iovec_buffers() function
- Merged io_uring_init_buffer_pattern() into unified
init_iovec_buffers() function that supports both rotating and
simple character patterns
- Removed io_uring_init_buffer_pattern() from io_uring_common.h as it's
only used in io_uring04.c
- Link to V2: https://lore.kernel.org/ltp/[email protected]/T/

V2 changes:
- Use guarded buffer(including iovec) allocation
- Move setup/cleanup code from run to appropriate path
- Add a function to map the OP to the enum name
- Define and use generic cleanup functions
- Add a buffer size 0 in the middle of the iovec
- Simplify setup_io_uring_test to use common code.
- Link to V1: https://lore.kernel.org/ltp/[email protected]/T/#t

Changes after RFC patch series:
- Addressed review comments
- Refactored io_uring01 test to use common code
- Removed git tags
- Link to RFC: https://lore.kernel.org/ltp/[email protected]/T/#t

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/io_uring/.gitignore |   1 +
 .../kernel/syscalls/io_uring/io_uring04.c     | 221 ++++++++++++++++++
 .../syscalls/io_uring/io_uring_common.h       |  13 --
 4 files changed, 223 insertions(+), 13 deletions(-)
 create mode 100644 testcases/kernel/syscalls/io_uring/io_uring04.c
runtest/syscalls +1 -0
index 5025b259f..aa7a91d97 100644
@@ -1901,6 +1901,7 @@ membarrier01 membarrier01
 io_uring01 io_uring01
 io_uring02 io_uring02
 io_uring03 io_uring03
+io_uring04 io_uring04
 
 # Tests below may cause kernel memory leak
 perf_event_open03 perf_event_open03
testcases/kernel/syscalls/io_uring/.gitignore +1 -0
index 9382ae413..36cd24662 100644
@@ -1,3 +1,4 @@
 /io_uring01
 /io_uring02
 /io_uring03
+/io_uring04
testcases/kernel/syscalls/io_uring/io_uring04.c new file +221 -0

221 lines not on this page · raw message

testcases/kernel/syscalls/io_uring/io_uring_common.h +0 -13
index aa31339fb..7816b55dc 100644
@@ -230,19 +230,6 @@ static inline void io_uring_wait_cqe(struct io_uring_submit *s,
 	*cring->head = head + 1;
 }
 
-/*
- * Initialize buffer with a repeating character pattern
- * Useful for creating test data with predictable patterns
- */
-static inline void io_uring_init_buffer_pattern(char *buf, size_t size,
-						char pattern)
-{
-	size_t i;
-
-	for (i = 0; i < size; i++)
-		buf[i] = pattern;
-}
-
 /*
  * Submit and wait for a non-vectored I/O operation
  * Combines io_uring_submit_sqe() and io_uring_wait_cqe() with result reporting
Signature · 5 lines
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Sachin,

Quoted 5 lines · Sachin Sant

io_uring: Add test for READV and WRITEV operations

Additionally merge io_uring_init_buffer_pattern() into unified init_iovec_buffers() function that supports both rotating and simple character patterns

This mixes two logical changes in one commit. io_uring_init_buffer_pattern() was unused by any existing test; its removal should be a separate preceding commit, e.g. "io_uring: remove unused io_uring_init_buffer_pattern()".

[...]

testcases/kernel/syscalls/io_uring/io_uring04.c line 197

Quoted 9 lines
testcases/kernel/syscalls/io_uring/io_uring04.c new file +9 -0
+static void setup(void)
+{
+	io_uring_setup_supported_by_kernel();
+	sigemptyset(&sig);
+	memset(&s, 0, sizeof(s));
+	io_uring_setup_queue(&s, QUEUE_DEPTH, 0);
+	init_iovec_buffers(write_iovs, NUM_VECS, 'A', 1);
+	clear_iovec_buffers(read_iovs, NUM_VECS);
+}

read_iovs is modified by READV in run() but only cleared in setup(). With -i, the second iteration starts with stale data. Add clear_iovec_buffers(read_iovs, NUM_VECS) at the top of run().

---
Note:

Our agent completed the review of the patch. The full review can be found at: https://patchwork.ozlabs.org/project/ltp/list/?series=500082

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp