* [PATCH liburing 0/3] test lazy poll wq activation
@ 2023-01-16 16:46 Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 1/3] tests: refactor poll-many.c Pavel Begunkov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-01-16 16:46 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Some tests around DEFER_TASKRUN and lazy poll activation, with
3/3 specifically testing the feature with disabled.
Pavel Begunkov (3):
tests: refactor poll-many.c
tests: test DEFER_TASKRUN in poll-many
tests: lazy pollwq activation for disabled rings
test/poll-many.c | 60 ++++++++++++++++++++----------
test/poll.c | 96 ++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 130 insertions(+), 26 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH liburing 1/3] tests: refactor poll-many.c
2023-01-16 16:46 [PATCH liburing 0/3] test lazy poll wq activation Pavel Begunkov
@ 2023-01-16 16:46 ` Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 2/3] tests: test DEFER_TASKRUN in poll-many Pavel Begunkov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-01-16 16:46 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Use right return codes and extract the testing into a function
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/poll-many.c | 46 +++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/test/poll-many.c b/test/poll-many.c
index dfbeeab..ebf22e8 100644
--- a/test/poll-many.c
+++ b/test/poll-many.c
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include "liburing.h"
+#include "helpers.h"
#define NFILES 5000
#define BATCH 500
@@ -137,6 +138,21 @@ static int arm_polls(struct io_uring *ring)
return 0;
}
+static int do_test(struct io_uring *ring)
+{
+ int i;
+
+ if (arm_polls(ring))
+ return 1;
+
+ for (i = 0; i < NLOOPS; i++) {
+ trigger_polls();
+ if (reap_polls(ring))
+ return 1;
+ }
+ return 0;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring;
@@ -149,7 +165,7 @@ int main(int argc, char *argv[])
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
perror("getrlimit");
- goto err_noring;
+ return T_EXIT_FAIL;
}
if (rlim.rlim_cur < (2 * NFILES + 5)) {
@@ -159,14 +175,14 @@ int main(int argc, char *argv[])
if (errno == EPERM)
goto err_nofail;
perror("setrlimit");
- goto err_noring;
+ return T_EXIT_FAIL;
}
}
for (i = 0; i < NFILES; i++) {
if (pipe(p[i].fd) < 0) {
perror("pipe");
- goto err_noring;
+ return T_EXIT_FAIL;
}
}
@@ -176,31 +192,23 @@ int main(int argc, char *argv[])
if (ret) {
if (ret == -EINVAL) {
fprintf(stdout, "No CQSIZE, trying without\n");
- ret = io_uring_queue_init(RING_SIZE, &ring, 0);
+
+ params.flags &= ~IORING_SETUP_CQSIZE;
+ params.cq_entries = 0;
+ ret = io_uring_queue_init_params(RING_SIZE, &ring, ¶ms);
if (ret) {
fprintf(stderr, "ring setup failed: %d\n", ret);
- return 1;
+ return T_EXIT_FAIL;
}
}
}
- if (arm_polls(&ring))
- goto err;
-
- for (i = 0; i < NLOOPS; i++) {
- trigger_polls();
- ret = reap_polls(&ring);
- if (ret)
- goto err;
+ if (do_test(&ring)) {
+ fprintf(stderr, "test (normal) failed\n");
+ return T_EXIT_FAIL;
}
-
io_uring_queue_exit(&ring);
return 0;
-err:
- io_uring_queue_exit(&ring);
-err_noring:
- fprintf(stderr, "poll-many failed\n");
- return 1;
err_nofail:
fprintf(stderr, "poll-many: not enough files available (and not root), "
"skipped\n");
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH liburing 2/3] tests: test DEFER_TASKRUN in poll-many
2023-01-16 16:46 [PATCH liburing 0/3] test lazy poll wq activation Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 1/3] tests: refactor poll-many.c Pavel Begunkov
@ 2023-01-16 16:46 ` Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 3/3] tests: lazy pollwq activation for disabled rings Pavel Begunkov
2023-01-16 17:49 ` [PATCH liburing 0/3] test lazy poll wq activation Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-01-16 16:46 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
We want to extend DEFER_TASKRUN test coverage for polling, so
make poll-many.c to test it.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/poll-many.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/test/poll-many.c b/test/poll-many.c
index ebf22e8..da3da21 100644
--- a/test/poll-many.c
+++ b/test/poll-many.c
@@ -208,6 +208,20 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}
io_uring_queue_exit(&ring);
+
+ if (t_probe_defer_taskrun()) {
+ params.flags |= IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN;
+ ret = io_uring_queue_init_params(RING_SIZE, &ring, ¶ms);
+ if (ret) {
+ fprintf(stderr, "ring DEFER setup failed: %d\n", ret);
+ return T_EXIT_FAIL;
+ }
+ if (do_test(&ring)) {
+ fprintf(stderr, "test (DEFER) failed\n");
+ return T_EXIT_FAIL;
+ }
+ io_uring_queue_exit(&ring);
+ }
return 0;
err_nofail:
fprintf(stderr, "poll-many: not enough files available (and not root), "
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH liburing 3/3] tests: lazy pollwq activation for disabled rings
2023-01-16 16:46 [PATCH liburing 0/3] test lazy poll wq activation Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 1/3] tests: refactor poll-many.c Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 2/3] tests: test DEFER_TASKRUN in poll-many Pavel Begunkov
@ 2023-01-16 16:46 ` Pavel Begunkov
2023-01-16 17:49 ` [PATCH liburing 0/3] test lazy poll wq activation Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-01-16 16:46 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
We have some internal changes in how ring polling is done, i.e. lazy
pollwq activation, test it when we start polling a disabled ring and
so before the task has been assigned.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/poll.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 89 insertions(+), 7 deletions(-)
diff --git a/test/poll.c b/test/poll.c
index a7db7dc..7b90f3d 100644
--- a/test/poll.c
+++ b/test/poll.c
@@ -12,6 +12,7 @@
#include <poll.h>
#include <sys/wait.h>
#include <error.h>
+#include <assert.h>
#include "helpers.h"
#include "liburing.h"
@@ -22,6 +23,15 @@ static void do_setsockopt(int fd, int level, int optname, int val)
error(1, errno, "setsockopt %d.%d: %d", level, optname, val);
}
+static bool check_cq_empty(struct io_uring *ring)
+{
+ struct io_uring_cqe *cqe = NULL;
+ int ret;
+
+ ret = io_uring_peek_cqe(ring, &cqe); /* nothing should be there */
+ return ret == -EAGAIN;
+}
+
static int test_basic(void)
{
struct io_uring_cqe *cqe;
@@ -110,9 +120,6 @@ static int test_missing_events(void)
char buf[2] = {};
int res_mask = 0;
- if (!t_probe_defer_taskrun())
- return 0;
-
ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
IORING_SETUP_DEFER_TASKRUN);
if (ret) {
@@ -180,6 +187,66 @@ static int test_missing_events(void)
return 0;
}
+static int test_disabled_ring_lazy_polling(int early_poll)
+{
+ struct io_uring_cqe *cqe;
+ struct io_uring_sqe *sqe;
+ struct io_uring ring, ring2;
+ unsigned head;
+ int ret, i = 0;
+
+ ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
+ IORING_SETUP_DEFER_TASKRUN |
+ IORING_SETUP_R_DISABLED);
+ if (ret) {
+ fprintf(stderr, "ring setup failed: %d\n", ret);
+ return 1;
+ }
+ ret = io_uring_queue_init(8, &ring2, 0);
+ if (ret) {
+ fprintf(stderr, "ring2 setup failed: %d\n", ret);
+ return 1;
+ }
+
+ if (early_poll) {
+ /* start polling disabled DEFER_TASKRUN ring */
+ sqe = io_uring_get_sqe(&ring2);
+ io_uring_prep_poll_add(sqe, ring.ring_fd, POLLIN);
+ ret = io_uring_submit(&ring2);
+ assert(ret == 1);
+ assert(check_cq_empty(&ring2));
+ }
+
+ /* enable rings, which should also activate pollwq */
+ ret = io_uring_enable_rings(&ring);
+ assert(ret >= 0);
+
+ if (!early_poll) {
+ /* start polling enabled DEFER_TASKRUN ring */
+ sqe = io_uring_get_sqe(&ring2);
+ io_uring_prep_poll_add(sqe, ring.ring_fd, POLLIN);
+ ret = io_uring_submit(&ring2);
+ assert(ret == 1);
+ assert(check_cq_empty(&ring2));
+ }
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_nop(sqe);
+ ret = io_uring_submit(&ring);
+ assert(ret == 1);
+
+ io_uring_for_each_cqe(&ring2, head, cqe) {
+ i++;
+ }
+ if (i != 1) {
+ fprintf(stderr, "fail, polling stuck\n");
+ return 1;
+ }
+ io_uring_queue_exit(&ring);
+ io_uring_queue_exit(&ring2);
+ return 0;
+}
+
int main(int argc, char *argv[])
{
int ret;
@@ -193,10 +260,25 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}
- ret = test_missing_events();
- if (ret) {
- fprintf(stderr, "test_missing_events() failed %i\n", ret);
- return T_EXIT_FAIL;
+
+ if (t_probe_defer_taskrun()) {
+ ret = test_missing_events();
+ if (ret) {
+ fprintf(stderr, "test_missing_events() failed %i\n", ret);
+ return T_EXIT_FAIL;
+ }
+
+ ret = test_disabled_ring_lazy_polling(false);
+ if (ret) {
+ fprintf(stderr, "test_disabled_ring_lazy_polling(false) failed %i\n", ret);
+ return T_EXIT_FAIL;
+ }
+
+ ret = test_disabled_ring_lazy_polling(true);
+ if (ret) {
+ fprintf(stderr, "test_disabled_ring_lazy_polling(true) failed %i\n", ret);
+ return T_EXIT_FAIL;
+ }
}
return 0;
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH liburing 0/3] test lazy poll wq activation
2023-01-16 16:46 [PATCH liburing 0/3] test lazy poll wq activation Pavel Begunkov
` (2 preceding siblings ...)
2023-01-16 16:46 ` [PATCH liburing 3/3] tests: lazy pollwq activation for disabled rings Pavel Begunkov
@ 2023-01-16 17:49 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2023-01-16 17:49 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
On Mon, 16 Jan 2023 16:46:06 +0000, Pavel Begunkov wrote:
> Some tests around DEFER_TASKRUN and lazy poll activation, with
> 3/3 specifically testing the feature with disabled.
>
> Pavel Begunkov (3):
> tests: refactor poll-many.c
> tests: test DEFER_TASKRUN in poll-many
> tests: lazy pollwq activation for disabled rings
>
> [...]
Applied, thanks!
[1/3] tests: refactor poll-many.c
commit: cfd00c3bfe18452a06792b7269a59d269f62d637
[2/3] tests: test DEFER_TASKRUN in poll-many
commit: a2ab37070b9453e43a94b88878ec3a4d780a4ba6
[3/3] tests: lazy pollwq activation for disabled rings
commit: 849f5ba89b0d1ccf9d825160bf8560ad9901c48b
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-16 18:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-16 16:46 [PATCH liburing 0/3] test lazy poll wq activation Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 1/3] tests: refactor poll-many.c Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 2/3] tests: test DEFER_TASKRUN in poll-many Pavel Begunkov
2023-01-16 16:46 ` [PATCH liburing 3/3] tests: lazy pollwq activation for disabled rings Pavel Begunkov
2023-01-16 17:49 ` [PATCH liburing 0/3] test lazy poll wq activation Jens Axboe
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.