public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing v4] test that unregister_files processes task work
@ 2022-11-08 12:42 Dylan Yudaken
  2022-11-08 12:50 ` Ammar Faizi
  2022-11-08 14:13 ` Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: Dylan Yudaken @ 2022-11-08 12:42 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, Dylan Yudaken

Ensure that unregister_files processes task work from defer_taskrun even
when not explicitly flushed.

Signed-off-by: Dylan Yudaken <[email protected]>
---

v4:
 - I didnt actually send the updated patch in v3

v3:
 - look at register_files return code

v2:
 - fix return code when ring init fails
 test/file-register.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/test/file-register.c b/test/file-register.c
index 634ef8159cec..f48eceb43e44 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -935,6 +935,59 @@ static int test_zero_range_alloc(struct io_uring *ring, int fds[2])
 	return 0;
 }
 
+static int test_defer_taskrun(void)
+{
+	struct io_uring_sqe *sqe;
+	struct io_uring ring;
+	int ret, fds[2];
+	char buff = 'x';
+
+	ret = io_uring_queue_init(8, &ring,
+				  IORING_SETUP_DEFER_TASKRUN | IORING_SETUP_SINGLE_ISSUER);
+	if (ret) {
+		fprintf(stderr, "ring init\n");
+		return 1;
+	}
+
+	ret = pipe(fds);
+	if (ret) {
+		fprintf(stderr, "bad pipes\n");
+		return 1;
+	}
+
+	ret = io_uring_register_files(&ring, &fds[0], 2);
+	if (ret) {
+		fprintf(stderr, "bad register %d\n", ret);
+		return 1;
+	}
+
+	sqe = io_uring_get_sqe(&ring);
+	io_uring_prep_read(sqe, 0, &buff, 1, 0);
+	sqe->flags |= IOSQE_FIXED_FILE;
+	ret = io_uring_submit(&ring);
+	if (ret != 1) {
+		fprintf(stderr, "bad submit\n");
+		return 1;
+	}
+
+	ret = write(fds[1], &buff, 1);
+	if (ret != 1) {
+		fprintf(stderr, "bad pipe write\n");
+		return 1;
+	}
+
+	ret = io_uring_unregister_files(&ring);
+	if (ret) {
+		fprintf(stderr, "bad unregister %d\n", ret);
+		return 1;
+	}
+
+	close(fds[0]);
+	close(fds[1]);
+	io_uring_queue_exit(&ring);
+	return 0;
+}
+
 static int test_file_alloc_ranges(void)
 {
 	struct io_uring ring;
@@ -1120,5 +1173,13 @@ int main(int argc, char *argv[])
 		return T_EXIT_FAIL;
 	}
 
+	if (t_probe_defer_taskrun()) {
+		ret = test_defer_taskrun();
+		if (ret) {
+			fprintf(stderr, "test_defer_taskrun failed\n");
+			return T_EXIT_FAIL;
+		}
+	}
+
 	return T_EXIT_PASS;
 }

base-commit: 754bc068ec482c5338a07dd74b7d3892729bb847
-- 
2.30.2


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

* Re: [PATCH liburing v4] test that unregister_files processes task work
  2022-11-08 12:42 [PATCH liburing v4] test that unregister_files processes task work Dylan Yudaken
@ 2022-11-08 12:50 ` Ammar Faizi
  2022-11-08 14:11   ` Jens Axboe
  2022-11-08 14:13 ` Jens Axboe
  1 sibling, 1 reply; 4+ messages in thread
From: Ammar Faizi @ 2022-11-08 12:50 UTC (permalink / raw)
  To: Dylan Yudaken; +Cc: io-uring Mailing List, Jens Axboe, Pavel Begunkov

On 11/8/22 7:42 PM, Dylan Yudaken wrote:
> Ensure that unregister_files processes task work from defer_taskrun even
> when not explicitly flushed.
> 
> Signed-off-by: Dylan Yudaken <[email protected]>

I feel a bit irritated because the close() and io_uring_queue_exit()
don't get invoked in the error paths. But not a big deal, since in the
test we'll be exiting soon after that :p

Reviewed-by: Ammar Faizi <[email protected]>

-- 
Ammar Faizi


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

* Re: [PATCH liburing v4] test that unregister_files processes task work
  2022-11-08 12:50 ` Ammar Faizi
@ 2022-11-08 14:11   ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-11-08 14:11 UTC (permalink / raw)
  To: Ammar Faizi, Dylan Yudaken; +Cc: io-uring Mailing List, Pavel Begunkov

On 11/8/22 5:50 AM, Ammar Faizi wrote:
> On 11/8/22 7:42 PM, Dylan Yudaken wrote:
>> Ensure that unregister_files processes task work from defer_taskrun even
>> when not explicitly flushed.
>>
>> Signed-off-by: Dylan Yudaken <[email protected]>
> 
> I feel a bit irritated because the close() and io_uring_queue_exit()
> don't get invoked in the error paths. But not a big deal, since in the
> test we'll be exiting soon after that :p

Yeah, lots of tests to that - in case of error, just return the error
and the test will exit anyway. Obviously not kosher for a real
application, but I view it like leaking heap data in that regard. It'll
get reaped when the application goes away, and is again not something
you'd do in a real application.

-- 
Jens Axboe

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

* Re: [PATCH liburing v4] test that unregister_files processes task work
  2022-11-08 12:42 [PATCH liburing v4] test that unregister_files processes task work Dylan Yudaken
  2022-11-08 12:50 ` Ammar Faizi
@ 2022-11-08 14:13 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-11-08 14:13 UTC (permalink / raw)
  To: Dylan Yudaken, Pavel Begunkov; +Cc: io-uring

On Tue, 8 Nov 2022 04:42:07 -0800, Dylan Yudaken wrote:
> Ensure that unregister_files processes task work from defer_taskrun even
> when not explicitly flushed.
> 
> 

Applied, thanks!

[1/1] test that unregister_files processes task work
      commit: 78463f30a5f3235c8cce82cbf1b8ff437f6536cd

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-11-08 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-08 12:42 [PATCH liburing v4] test that unregister_files processes task work Dylan Yudaken
2022-11-08 12:50 ` Ammar Faizi
2022-11-08 14:11   ` Jens Axboe
2022-11-08 14:13 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox