io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH liburing 0/2] test: fix poll-mshot-update tests
@ 2022-07-21 16:04 Dylan Yudaken
  2022-07-21 16:04 ` [PATCH liburing 1/2] fixup poll-mshot-update Dylan Yudaken
                   ` (2 more replies)
  0 siblings, 3 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 look at the IORING_CQE_F_MORE flag, and so could start failing.
Update it to do this in patch 1, and then patch 2 runs the test with more/less
overflows to test these codepaths

Dylan Yudaken (2):
  fixup poll-mshot-update
  test: have poll-mshot-update run with both big and small cqe

 test/poll-mshot-update.c | 116 ++++++++++++++++++++++++++++-----------
 1 file changed, 83 insertions(+), 33 deletions(-)


base-commit: 4e6eec8bdea906fe5341c97aef96986d605004e9
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [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 <dylany@fb.com>
---
 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 <dylany@fb.com>
---
 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, &params);
 	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

* Re: [PATCH liburing 0/2] test: fix poll-mshot-update tests
  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 ` [PATCH liburing 2/2] test: have poll-mshot-update run with both big and small cqe Dylan Yudaken
@ 2022-07-21 16:50 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-07-21 16:50 UTC (permalink / raw)
  To: asml.silence, dylany; +Cc: io-uring, Kernel-team

On Thu, 21 Jul 2022 09:04:04 -0700, Dylan Yudaken wrote:
> This test did not look at the IORING_CQE_F_MORE flag, and so could start failing.
> Update it to do this in patch 1, and then patch 2 runs the test with more/less
> overflows to test these codepaths
> 
> Dylan Yudaken (2):
>   fixup poll-mshot-update
>   test: have poll-mshot-update run with both big and small cqe
> 
> [...]

Applied, thanks!

[1/2] fixup poll-mshot-update
      commit: 6451f3d9c0d06537a87d2adbe88c7f83aa0de787
[2/2] test: have poll-mshot-update run with both big and small cqe
      commit: 3609e11ccce8a9bc1ce36a3191fa8e25dd762932

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-21 16:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).