* [PATCH liburing 1/2] fixup poll-mshot-update
2022-07-21 16:04 [PATCH liburing 0/2] test: fix poll-mshot-update tests Dylan Yudaken
@ 2022-07-21 16:04 ` Dylan Yudaken
2022-07-21 16:04 ` [PATCH liburing 2/2] test: have poll-mshot-update run with both big and small cqe Dylan Yudaken
2022-07-21 16:50 ` [PATCH liburing 0/2] test: fix poll-mshot-update tests Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Dylan Yudaken @ 2022-07-21 16:04 UTC (permalink / raw)
To: axboe, asml.silence; +Cc: io-uring, Kernel-team, Dylan Yudaken
this test did not notice when poll was cancelled.
update it to notice, and rearm poll
Signed-off-by: Dylan Yudaken <[email protected]>
---
test/poll-mshot-update.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index caedb6fddc4b..e01befcfa7eb 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -75,6 +75,20 @@ static int arm_poll(struct io_uring *ring, int off)
return 0;
}
+static int submit_arm_poll(struct io_uring *ring, int off)
+{
+ int ret;
+
+ ret = arm_poll(ring, off);
+ if (ret)
+ return ret;
+
+ ret = io_uring_submit(ring);
+ if (ret < 0)
+ return ret;
+ return ret == 1 ? 0 : -1;
+}
+
static int reap_polls(struct io_uring *ring)
{
struct io_uring_cqe *cqe;
@@ -106,6 +120,18 @@ static int reap_polls(struct io_uring *ring)
off = cqe->user_data;
if (off == 0x12345678)
goto seen;
+ if (!(cqe->flags & IORING_CQE_F_MORE)) {
+ /* need to re-arm poll */
+ ret = submit_arm_poll(ring, off);
+ if (ret)
+ break;
+ if (cqe->res <= 0) {
+ /* retry this one */
+ i--;
+ goto seen;
+ }
+ }
+
ret = read(p[off].fd[0], &c, 1);
if (ret != 1) {
if (ret == -1 && errno == EAGAIN)
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH liburing 2/2] test: have poll-mshot-update run with both big and small cqe
2022-07-21 16:04 [PATCH liburing 0/2] test: fix poll-mshot-update tests Dylan Yudaken
2022-07-21 16:04 ` [PATCH liburing 1/2] fixup poll-mshot-update Dylan Yudaken
@ 2022-07-21 16:04 ` Dylan Yudaken
2022-07-21 16:50 ` [PATCH liburing 0/2] test: fix poll-mshot-update tests Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Dylan Yudaken @ 2022-07-21 16:04 UTC (permalink / raw)
To: axboe, asml.silence; +Cc: io-uring, Kernel-team, Dylan Yudaken
Run the test twice, with and without overflow to make sure more codepaths
are tested.
Signed-off-by: Dylan Yudaken <[email protected]>
---
test/poll-mshot-update.c | 90 +++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 33 deletions(-)
diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index e01befcfa7eb..eeb725437cc8 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -213,52 +213,23 @@ static int arm_polls(struct io_uring *ring)
return 0;
}
-int main(int argc, char *argv[])
+static int run(int cqe)
{
struct io_uring ring;
struct io_uring_params params = { };
- struct rlimit rlim;
pthread_t thread;
int i, j, ret;
- if (argc > 1)
- return 0;
-
- ret = has_poll_update();
- if (ret < 0) {
- fprintf(stderr, "poll update check failed %i\n", ret);
- return -1;
- } else if (!ret) {
- fprintf(stderr, "no poll update, skip\n");
- return 0;
- }
-
- if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
- perror("getrlimit");
- goto err_noring;
- }
-
- if (rlim.rlim_cur < (2 * NFILES + 5)) {
- rlim.rlim_cur = (2 * NFILES + 5);
- rlim.rlim_max = rlim.rlim_cur;
- if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
- if (errno == EPERM)
- goto err_nofail;
- perror("setrlimit");
- goto err_noring;
- }
- }
-
for (i = 0; i < NFILES; i++) {
if (pipe(p[i].fd) < 0) {
perror("pipe");
- goto err_noring;
+ return 1;
}
fcntl(p[i].fd[0], F_SETFL, O_NONBLOCK);
}
params.flags = IORING_SETUP_CQSIZE;
- params.cq_entries = 4096;
+ params.cq_entries = cqe;
ret = io_uring_queue_init_params(RING_SIZE, &ring, ¶ms);
if (ret) {
if (ret == -EINVAL) {
@@ -286,10 +257,63 @@ int main(int argc, char *argv[])
}
io_uring_queue_exit(&ring);
+ for (i = 0; i < NFILES; i++) {
+ close(p[i].fd[0]);
+ close(p[i].fd[1]);
+ }
return 0;
err:
io_uring_queue_exit(&ring);
-err_noring:
+ return 1;
+}
+
+int main(int argc, char *argv[])
+{
+ struct rlimit rlim;
+ int ret;
+
+ if (argc > 1)
+ return 0;
+
+ ret = has_poll_update();
+ if (ret < 0) {
+ fprintf(stderr, "poll update check failed %i\n", ret);
+ return -1;
+ } else if (!ret) {
+ fprintf(stderr, "no poll update, skip\n");
+ return 0;
+ }
+
+ if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ perror("getrlimit");
+ goto err;
+ }
+
+ if (rlim.rlim_cur < (2 * NFILES + 5)) {
+ rlim.rlim_cur = (2 * NFILES + 5);
+ rlim.rlim_max = rlim.rlim_cur;
+ if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ if (errno == EPERM)
+ goto err_nofail;
+ perror("setrlimit");
+ goto err;
+ }
+ }
+
+ ret = run(1024);
+ if (ret) {
+ fprintf(stderr, "run(1024) failed\n");
+ goto err;
+ }
+
+ ret = run(8192);
+ if (ret) {
+ fprintf(stderr, "run(8192) failed\n");
+ goto err;
+ }
+
+ return 0;
+err:
fprintf(stderr, "poll-many failed\n");
return 1;
err_nofail:
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread