public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 4/5] tests/msg_ring: refactor test_remote
Date: Tue, 24 Jan 2023 01:21:48 +0000	[thread overview]
Message-ID: <1c0e97492c0010a65c5c5f42450350b37c1a3809.1674523156.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Refactor test_remote() by folding all pthread accounting inside of it

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/msg-ring.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/test/msg-ring.c b/test/msg-ring.c
index 66c60b3..495c127 100644
--- a/test/msg-ring.c
+++ b/test/msg-ring.c
@@ -93,17 +93,23 @@ static void *wait_cqe_fn(void *data)
 		goto err;
 	}
 
+	io_uring_cqe_seen(ring, cqe);
 	return NULL;
 err:
+	io_uring_cqe_seen(ring, cqe);
 	return (void *) (unsigned long) 1;
 }
 
 static int test_remote(struct io_uring *ring, struct io_uring *target)
 {
+	pthread_t thread;
+	void *tret;
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
 	int ret;
 
+	pthread_create(&thread, NULL, wait_cqe_fn, target);
+
 	sqe = io_uring_get_sqe(ring);
 	if (!sqe) {
 		fprintf(stderr, "get sqe failed\n");
@@ -134,6 +140,7 @@ static int test_remote(struct io_uring *ring, struct io_uring *target)
 	}
 
 	io_uring_cqe_seen(ring, cqe);
+	pthread_join(thread, &tret);
 	return 0;
 err:
 	return 1;
@@ -237,8 +244,6 @@ static int test_disabled_ring(struct io_uring *ring, int flags)
 int main(int argc, char *argv[])
 {
 	struct io_uring ring, ring2, pring;
-	pthread_t thread;
-	void *tret;
 	int ret, i;
 
 	if (argc > 1)
@@ -287,18 +292,13 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	pthread_create(&thread, NULL, wait_cqe_fn, &ring2);
-
 	ret = test_remote(&ring, &ring2);
 	if (ret) {
 		fprintf(stderr, "test_remote failed\n");
 		return T_EXIT_FAIL;
 	}
 
-	pthread_join(thread, &tret);
-
 	io_uring_queue_exit(&ring);
-	io_uring_queue_exit(&ring2);
 	io_uring_queue_exit(&pring);
 
 	if (t_probe_defer_taskrun()) {
@@ -337,5 +337,6 @@ int main(int argc, char *argv[])
 
 	}
 
+	io_uring_queue_exit(&ring2);
 	return T_EXIT_PASS;
 }
-- 
2.38.1


  parent reply	other threads:[~2023-01-24  1:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24  1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
2023-01-24  1:21 ` [PATCH liburing 1/5] tests/msg_ring: use correct exit codes Pavel Begunkov
2023-01-24  1:21 ` [PATCH liburing 2/5] tests/msg_ring: test msg_ring with deferred tw Pavel Begunkov
2023-01-24  1:21 ` [PATCH liburing 3/5] test/msg_ring: test msg_ring to a disabled ring Pavel Begunkov
2023-01-24  1:21 ` Pavel Begunkov [this message]
2023-01-24  1:21 ` [PATCH liburing 5/5] tests/msg_ring: remote submit to a deferred tw ring Pavel Begunkov
2023-01-24  2:31 ` [PATCH liburing 0/5] deferred tw msg_ring tests Jens Axboe

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=1c0e97492c0010a65c5c5f42450350b37c1a3809.1674523156.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