public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing] test/drain: test draining linked timeouts
Date: Tue, 26 Jan 2021 23:25:19 +0000	[thread overview]
Message-ID: <b5213397eaeb9d6c7225b8d6dcfa6faae22b5ab0.1611703489.git.asml.silence@gmail.com> (raw)

Make sure references are accounted well when we defer reqs with linked
timeouts.

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

diff --git a/test/defer.c b/test/defer.c
index 05833d4..4bcc1cc 100644
--- a/test/defer.c
+++ b/test/defer.c
@@ -148,6 +148,41 @@ err:
 	return 1;
 }
 
+static int test_drain_with_linked_timeout(struct io_uring *ring)
+{
+	const int nr = 5;
+	struct __kernel_timespec ts = { .tv_sec = 1, .tv_nsec = 0, };
+	struct test_context ctx;
+	int ret, i;
+
+	if (init_context(&ctx, ring, nr * 2))
+		return 1;
+
+	for (i = 0; i < nr; i++) {
+		io_uring_prep_timeout(ctx.sqes[2 * i], &ts, 0, 0);
+		ctx.sqes[2 * i]->flags |= IOSQE_IO_LINK;
+		io_uring_prep_link_timeout(ctx.sqes[2 * i + 1], &ts, 0);
+	}
+
+	/* stall them all */
+	ctx.sqes[0]->flags |= IOSQE_IO_DRAIN;
+
+	ret = io_uring_submit(ring);
+	if (ret <= 0) {
+		printf("sqe submit failed: %d\n", ret);
+		goto err;
+	}
+
+	if (wait_cqes(&ctx))
+		goto err;
+
+	free_context(&ctx);
+	return 0;
+err:
+	free_context(&ctx);
+	return 1;
+}
+
 static int run_drained(struct io_uring *ring, int nr)
 {
 	struct test_context ctx;
@@ -269,5 +304,11 @@ int main(int argc, char *argv[])
 		return ret;
 	}
 
+	ret = test_drain_with_linked_timeout(&ring);
+	if (ret) {
+		printf("test_drain_with_linked_timeout failed\n");
+		return ret;
+	}
+
 	return 0;
 }
-- 
2.24.0


                 reply	other threads:[~2021-01-27  7:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=b5213397eaeb9d6c7225b8d6dcfa6faae22b5ab0.1611703489.git.asml.silence@gmail.com \
    [email protected] \
    [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