From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH liburing 6/8] test/reg-wait: parameterise test_offsets
Date: Sat, 16 Nov 2024 21:27:46 +0000 [thread overview]
Message-ID: <939b7af82e46d7e857aec12cfaa74fbd42fab5a2.1731792294.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/reg-wait.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/test/reg-wait.c b/test/reg-wait.c
index 10ab3a2..ffe4c1d 100644
--- a/test/reg-wait.c
+++ b/test/reg-wait.c
@@ -68,23 +68,27 @@ static int test_invalid_sig(struct io_uring *ring)
return T_EXIT_PASS;
}
-static int test_offsets(struct io_uring *ring)
+static int test_offsets(struct io_uring *ring, struct io_uring_reg_wait *base,
+ size_t size, bool overallocated)
{
struct io_uring_cqe *cqe;
- int max_index = page_size / sizeof(struct io_uring_reg_wait);
+ int max_index = size / sizeof(struct io_uring_reg_wait);
struct io_uring_reg_wait *rw;
unsigned long offset;
+ int copy_size;
int ret;
- rw = reg + max_index;
- memcpy(rw, &brief_wait, sizeof(brief_wait));
+ if (overallocated) {
+ rw = base + max_index;
+ memcpy(rw, &brief_wait, sizeof(brief_wait));
+ }
ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index);
if (ret != -EFAULT) {
fprintf(stderr, "max+1 index failed: %d\n", ret);
return T_EXIT_FAIL;
}
- rw = reg + max_index - 1;
+ rw = base + max_index - 1;
memcpy(rw, &brief_wait, sizeof(brief_wait));
ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index - 1);
if (ret != -ETIME) {
@@ -100,8 +104,10 @@ static int test_offsets(struct io_uring *ring)
}
offset = page_size - sizeof(long);
- rw = (void *)reg + offset;
- memcpy(rw, &brief_wait, sizeof(brief_wait));
+ rw = (void *)base + offset;
+ copy_size = overallocated ? sizeof(brief_wait) : sizeof(long);
+ memcpy(rw, &brief_wait, copy_size);
+
ret = test_wait_reg_offset(ring, 1, offset);
if (ret != -EFAULT) {
fprintf(stderr, "OOB offset failed: %d\n", ret);
@@ -109,7 +115,7 @@ static int test_offsets(struct io_uring *ring)
}
offset = 1;
- rw = (void *)reg + offset;
+ rw = (void *)base + offset;
memcpy(rw, &brief_wait, sizeof(brief_wait));
/* undefined behaviour, check the kernel doesn't crash */
(void)test_wait_reg_offset(ring, 1, offset);
@@ -201,7 +207,7 @@ static int test_wait_arg(void)
goto err;
}
- ret = test_offsets(&ring);
+ ret = test_offsets(&ring, buffer, page_size, true);
if (ret == T_EXIT_FAIL) {
fprintf(stderr, "test_offsets failed\n");
goto err;
--
2.46.0
next prev parent reply other threads:[~2024-11-16 21:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 21:27 [PATCH liburing 0/8] region test fixes + improvements Pavel Begunkov
2024-11-16 21:27 ` [PATCH liburing 1/8] test/reg-wait: fix test_regions Pavel Begunkov
2024-11-16 21:27 ` [PATCH liburing 2/8] test/reg-wait: pass right timeout indexes Pavel Begunkov
2024-11-16 21:27 ` [PATCH liburing 3/8] test/reg-wait: use queried page_size Pavel Begunkov
2024-11-16 21:27 ` [PATCH liburing 4/8] test/reg-wait: skip when R_DISABLED is not supported Pavel Begunkov
2024-11-16 21:27 ` [PATCH liburing 5/8] test/reg-wait: dedup regwait init Pavel Begunkov
2024-11-16 21:27 ` Pavel Begunkov [this message]
2024-11-16 21:27 ` [PATCH liburing 7/8] test/reg-wait: add registration helper Pavel Begunkov
2024-11-16 21:27 ` [PATCH liburing 8/8] test/reg-wait: test various sized regions Pavel Begunkov
2024-11-17 16:03 ` [PATCH liburing 0/8] region test fixes + improvements Jens Axboe
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=939b7af82e46d7e857aec12cfaa74fbd42fab5a2.1731792294.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
/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