public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH liburing 2/4] test/reg-wait: basic test + probing of kernel regions
Date: Wed, 20 Nov 2024 23:39:49 +0000	[thread overview]
Message-ID: <8a525a846002b2a899addbae52f922d9034b4257.1731987026.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/reg-wait.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test/reg-wait.c b/test/reg-wait.c
index 544cd48..9b18ab1 100644
--- a/test/reg-wait.c
+++ b/test/reg-wait.c
@@ -23,6 +23,8 @@ static const struct io_uring_reg_wait brief_wait = {
 	.ts.tv_nsec = 1000,
 };
 
+static bool has_kernel_regions;
+
 static int test_wait_reg_offset(struct io_uring *ring,
 				 unsigned wait_nr, unsigned long offset)
 {
@@ -380,6 +382,27 @@ static int test_regions(void)
 		return T_EXIT_FAIL;
 	}
 
+	rd.flags = 0;
+	rd.user_addr = 0;
+	ret = test_try_register_region(&mr, true);
+	if (ret == -EINVAL) {
+		has_kernel_regions = false;
+		goto out;
+	}
+	if (ret) {
+		fprintf(stderr, "test_try_register_region() failed kernel alloc %i\n", ret);
+		return T_EXIT_FAIL;
+	}
+
+	has_kernel_regions = true;
+	rd.flags = 0;
+	rd.user_addr = (__u64)(unsigned long)buffer;
+	ret = test_try_register_region(&mr, true);
+	if (!ret) {
+		fprintf(stderr, "test_try_register_region() failed uptr w kernel alloc %i\n", ret);
+		return T_EXIT_FAIL;
+	}
+out:
 	munmap(buffer, page_size);
 	return 0;
 }
-- 
2.46.0


  parent reply	other threads:[~2024-11-20 23:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 23:39 [PATCH liburing 0/4] test kernel allocated regions Pavel Begunkov
2024-11-20 23:39 ` [PATCH liburing 1/4] tests/reg-wait: test registering RO memory Pavel Begunkov
2024-11-20 23:39 ` Pavel Begunkov [this message]
2024-11-20 23:39 ` [PATCH liburing 3/4] test/reg-wait: add allocation abstraction Pavel Begunkov
2024-11-20 23:39 ` [PATCH liburing 4/4] test/reg-wait: test kernel allocated regions Pavel Begunkov

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=8a525a846002b2a899addbae52f922d9034b4257.1731987026.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