From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH liburing 7/8] test/reg-wait: add registration helper
Date: Sat, 16 Nov 2024 21:27:47 +0000 [thread overview]
Message-ID: <defbcb4f286b62c04dedaab54a7e7d1de0ad33e7.1731792294.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/reg-wait.c | 56 ++++++++++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 22 deletions(-)
diff --git a/test/reg-wait.c b/test/reg-wait.c
index ffe4c1d..559228f 100644
--- a/test/reg-wait.c
+++ b/test/reg-wait.c
@@ -32,6 +32,37 @@ static int test_wait_reg_offset(struct io_uring *ring,
sizeof(struct io_uring_reg_wait));
}
+static int __init_ring_with_region(struct io_uring *ring, unsigned ring_flags,
+ struct io_uring_mem_region_reg *pr,
+ bool disabled)
+{
+ int flags = disabled ? IORING_SETUP_R_DISABLED : 0;
+ int ret;
+
+ ret = io_uring_queue_init(8, ring, flags);
+ if (ret) {
+ if (ret != -EINVAL)
+ fprintf(stderr, "ring setup failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = io_uring_register_region(ring, pr);
+ if (ret)
+ goto err;
+
+ if (disabled) {
+ ret = io_uring_enable_rings(ring);
+ if (ret) {
+ fprintf(stderr, "io_uring_enable_rings failure %i\n", ret);
+ goto err;
+ }
+ }
+ return 0;
+err:
+ io_uring_queue_exit(ring);
+ return ret;
+}
+
static int page_size;
static struct io_uring_reg_wait *reg;
@@ -222,30 +253,11 @@ static int test_try_register_region(struct io_uring_mem_region_reg *pr,
bool disabled)
{
struct io_uring ring;
- int flags = 0;
int ret;
- if (disabled)
- flags = IORING_SETUP_R_DISABLED;
-
- ret = io_uring_queue_init(8, &ring, flags);
- if (ret) {
- if (ret != -EINVAL)
- fprintf(stderr, "ring setup failed: %d\n", ret);
- return ret;
- }
-
- ret = io_uring_register_region(&ring, pr);
- if (ret)
- goto err;
-
- if (disabled) {
- ret = io_uring_enable_rings(&ring);
- if (ret)
- fprintf(stderr, "io_uring_enable_rings failure %i\n", ret);
- }
-err:
- io_uring_queue_exit(&ring);
+ ret = __init_ring_with_region(&ring, 0, pr, disabled);
+ if (!ret)
+ io_uring_queue_exit(&ring);
return ret;
}
--
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 ` [PATCH liburing 6/8] test/reg-wait: parameterise test_offsets Pavel Begunkov
2024-11-16 21:27 ` Pavel Begunkov [this message]
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=defbcb4f286b62c04dedaab54a7e7d1de0ad33e7.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