All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH liburing 0/2] liburing: patches for drain bug
@ 2023-01-27 11:11 Dylan Yudaken
  2023-01-27 11:11 ` [PATCH liburing 1/2] add a test using drain with IORING_SETUP_DEFER_TASKRUN Dylan Yudaken
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dylan Yudaken @ 2023-01-27 11:11 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, kernel-team, Dylan Yudaken

Two patches for the drain bug I just sent a patch for.  Patch 1 definitely
fails, but patch 2 I am sending just in case as it exercises some more
code paths.

Dylan Yudaken (2): add a test using drain with IORING_SETUP_DEFER_TASKRUN
  run link_drain test with defer_taskrun too

 test/defer-taskrun.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
 test/link_drain.c    | 34 +++++++++++++++++++++++++++++----
 2 files changed, 75 insertions(+), 4 deletions(-)


base-commit: 328cad5e53a38b07139c9059cdff6cee359a5313
-- 
2.30.2


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

* [PATCH liburing 1/2] add a test using drain with IORING_SETUP_DEFER_TASKRUN
  2023-01-27 11:11 [PATCH liburing 0/2] liburing: patches for drain bug Dylan Yudaken
@ 2023-01-27 11:11 ` Dylan Yudaken
  2023-01-27 11:11 ` [PATCH liburing 2/2] run link_drain test with defer_taskrun too Dylan Yudaken
  2023-01-27 13:46 ` [PATCH liburing 0/2] liburing: patches for drain bug Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Dylan Yudaken @ 2023-01-27 11:11 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, kernel-team, Dylan Yudaken

This exposes a bug in the kernels handling of drain on an empty ring.

Signed-off-by: Dylan Yudaken <dylany@meta.com>
---
 test/defer-taskrun.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/test/defer-taskrun.c b/test/defer-taskrun.c
index 624285ec9582..a013cfdf02d9 100644
--- a/test/defer-taskrun.c
+++ b/test/defer-taskrun.c
@@ -283,6 +283,45 @@ static int test_ring_shutdown(void)
 	return 0;
 }
 
+static int test_drain(void)
+{
+	struct io_uring ring;
+	int ret, i, fd[2];
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
+	struct iovec iovecs[128];
+	char buff[ARRAY_SIZE(iovecs)];
+
+	ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
+					    IORING_SETUP_DEFER_TASKRUN |
+					    IORING_SETUP_TASKRUN_FLAG);
+	CHECK(!ret);
+
+	for (i = 0; i < ARRAY_SIZE(iovecs); i++) {
+		iovecs[i].iov_base = &buff[i];
+		iovecs[i].iov_len = 1;
+	}
+
+	ret = t_create_socket_pair(fd, true);
+	CHECK(!ret);
+
+	sqe = io_uring_get_sqe(&ring);
+	io_uring_prep_writev(sqe, fd[1], &iovecs[0], ARRAY_SIZE(iovecs), 0);
+	sqe->flags |= IOSQE_IO_DRAIN;
+	io_uring_submit(&ring);
+
+	for (i = 0; i < ARRAY_SIZE(iovecs); i++)
+		iovecs[i].iov_base = NULL;
+
+	CHECK(io_uring_wait_cqe(&ring, &cqe) == 0);
+	CHECK(cqe->res == 128);
+
+	close(fd[0]);
+	close(fd[1]);
+	io_uring_queue_exit(&ring);
+	return 0;
+}
+
 int main(int argc, char *argv[])
 {
 	int ret;
@@ -332,5 +371,11 @@ int main(int argc, char *argv[])
 		return T_EXIT_FAIL;
 	}
 
+	ret = test_drain();
+	if (ret) {
+		fprintf(stderr, "test_drain failed\n");
+		return T_EXIT_FAIL;
+	}
+
 	return T_EXIT_PASS;
 }
-- 
2.30.2


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

* [PATCH liburing 2/2] run link_drain test with defer_taskrun too
  2023-01-27 11:11 [PATCH liburing 0/2] liburing: patches for drain bug Dylan Yudaken
  2023-01-27 11:11 ` [PATCH liburing 1/2] add a test using drain with IORING_SETUP_DEFER_TASKRUN Dylan Yudaken
@ 2023-01-27 11:11 ` Dylan Yudaken
  2023-01-27 13:46 ` [PATCH liburing 0/2] liburing: patches for drain bug Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Dylan Yudaken @ 2023-01-27 11:11 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, kernel-team, Dylan Yudaken

Defer_taskrun seems to expose odd codepaths, so also run link_drain tests
using it.

Signed-off-by: Dylan Yudaken <dylany@meta.com>
---
 test/link_drain.c | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/test/link_drain.c b/test/link_drain.c
index 1a50c10d181d..86b0aa8db7fe 100644
--- a/test/link_drain.c
+++ b/test/link_drain.c
@@ -198,15 +198,17 @@ err:
 
 }
 
-int main(int argc, char *argv[])
+static int test_drain(bool defer)
 {
 	struct io_uring ring;
 	int i, ret;
+	unsigned int flags = 0;
 
-	if (argc > 1)
-		return 0;
+	if (defer)
+		flags = IORING_SETUP_SINGLE_ISSUER |
+			IORING_SETUP_DEFER_TASKRUN;
 
-	ret = io_uring_queue_init(100, &ring, 0);
+	ret = io_uring_queue_init(100, &ring, flags);
 	if (ret) {
 		printf("ring setup failed\n");
 		return 1;
@@ -227,3 +229,27 @@ int main(int argc, char *argv[])
 
 	return ret;
 }
+
+int main(int argc, char *argv[])
+{
+	int ret;
+
+	if (argc > 1)
+		return T_EXIT_SKIP;
+
+	ret = test_drain(false);
+	if (ret) {
+		fprintf(stderr, "test_drain(false) failed\n");
+		return T_EXIT_FAIL;
+	}
+
+	if (t_probe_defer_taskrun()) {
+		ret = test_drain(true);
+		if (ret) {
+			fprintf(stderr, "test_drain(true) failed\n");
+			return T_EXIT_FAIL;
+		}
+	}
+
+	return T_EXIT_PASS;
+}
-- 
2.30.2


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

* Re: [PATCH liburing 0/2] liburing: patches for drain bug
  2023-01-27 11:11 [PATCH liburing 0/2] liburing: patches for drain bug Dylan Yudaken
  2023-01-27 11:11 ` [PATCH liburing 1/2] add a test using drain with IORING_SETUP_DEFER_TASKRUN Dylan Yudaken
  2023-01-27 11:11 ` [PATCH liburing 2/2] run link_drain test with defer_taskrun too Dylan Yudaken
@ 2023-01-27 13:46 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2023-01-27 13:46 UTC (permalink / raw)
  To: Pavel Begunkov, Dylan Yudaken; +Cc: io-uring, kernel-team


On Fri, 27 Jan 2023 03:11:31 -0800, Dylan Yudaken wrote:
> Two patches for the drain bug I just sent a patch for.  Patch 1 definitely
> fails, but patch 2 I am sending just in case as it exercises some more
> code paths.
> 
> Dylan Yudaken (2): add a test using drain with IORING_SETUP_DEFER_TASKRUN
>   run link_drain test with defer_taskrun too
> 
> [...]

Applied, thanks!

[1/2] add a test using drain with IORING_SETUP_DEFER_TASKRUN
      (no commit info)
[2/2] run link_drain test with defer_taskrun too
      (no commit info)

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-01-27 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 11:11 [PATCH liburing 0/2] liburing: patches for drain bug Dylan Yudaken
2023-01-27 11:11 ` [PATCH liburing 1/2] add a test using drain with IORING_SETUP_DEFER_TASKRUN Dylan Yudaken
2023-01-27 11:11 ` [PATCH liburing 2/2] run link_drain test with defer_taskrun too Dylan Yudaken
2023-01-27 13:46 ` [PATCH liburing 0/2] liburing: patches for drain bug 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.