public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] test that unregister_files processes task work
@ 2022-11-07 12:35 Dylan Yudaken
  2022-11-07 13:04 ` Ammar Faizi
  0 siblings, 1 reply; 3+ messages in thread
From: Dylan Yudaken @ 2022-11-07 12:35 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, kernel-team, Dylan Yudaken

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

Signed-off-by: Dylan Yudaken <[email protected]>
---
 test/file-register.c | 55 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/test/file-register.c b/test/file-register.c
index 634ef8159cec..9a6e6cf971ae 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -935,6 +935,53 @@ 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)
+		return T_EXIT_SKIP;
+
+	ret = pipe(fds);
+	if (ret) {
+		fprintf(stderr, "bad pipes\n");
+		return 1;
+	}
+
+	ret = io_uring_register_files(&ring, &fds[0], 2);
+
+	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 +1167,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 failed\n");
+			return T_EXIT_FAIL;
+		}
+	}
+
 	return T_EXIT_PASS;
 }

base-commit: 754bc068ec482c5338a07dd74b7d3892729bb847
-- 
2.30.2


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

* Re: [PATCH liburing] test that unregister_files processes task work
  2022-11-07 12:35 [PATCH liburing] test that unregister_files processes task work Dylan Yudaken
@ 2022-11-07 13:04 ` Ammar Faizi
  2022-11-07 13:37   ` Dylan Yudaken
  0 siblings, 1 reply; 3+ messages in thread
From: Ammar Faizi @ 2022-11-07 13:04 UTC (permalink / raw)
  To: Dylan Yudaken, Jens Axboe, Pavel Begunkov
  Cc: io-uring Mailing List, Facebook Kernel Team

On 11/7/22 7:35 PM, Dylan Yudaken wrote:
> +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)
> +		return T_EXIT_SKIP;

You return T_EXIT_SKIP from test_defer_taskrun(). But the
call site is:

> +	if (t_probe_defer_taskrun()) {
> +		ret = test_defer_taskrun();
> +		if (ret) {
> +			fprintf(stderr, "test_defer failed\n");
> +			return T_EXIT_FAIL;
> +		}
> +	}

T_EXIT_SKIP is 77. So the block inside the "if" is taken.
End result you get T_EXIT_FAIL.

T_EXIT_SKIP in your code doesn't really mean skip.

-- 
Ammar Faizi


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

* Re: [PATCH liburing] test that unregister_files processes task work
  2022-11-07 13:04 ` Ammar Faizi
@ 2022-11-07 13:37   ` Dylan Yudaken
  0 siblings, 0 replies; 3+ messages in thread
From: Dylan Yudaken @ 2022-11-07 13:37 UTC (permalink / raw)
  To: Dylan Yudaken, [email protected], [email protected],
	[email protected]
  Cc: Kernel Team, [email protected]

On Mon, 2022-11-07 at 20:04 +0700, Ammar Faizi wrote:
> On 11/7/22 7:35 PM, Dylan Yudaken wrote:
> > +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)
> > +               return T_EXIT_SKIP;
> 
> You return T_EXIT_SKIP from test_defer_taskrun(). But the
> call site is:
> 
> > +       if (t_probe_defer_taskrun()) {
> > +               ret = test_defer_taskrun();
> > +               if (ret) {
> > +                       fprintf(stderr, "test_defer failed\n");
> > +                       return T_EXIT_FAIL;
> > +               }
> > +       }
> 
> T_EXIT_SKIP is 77. So the block inside the "if" is taken.
> End result you get T_EXIT_FAIL.
> 
> T_EXIT_SKIP in your code doesn't really mean skip.
> 

Ah yes - I added the probe and then forgot to take out the skip.
Thanks for spotting.

Dylan


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07 12:35 [PATCH liburing] test that unregister_files processes task work Dylan Yudaken
2022-11-07 13:04 ` Ammar Faizi
2022-11-07 13:37   ` Dylan Yudaken

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