All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Subject: Re: [PATCH liburing] tests: test CQE ordering on early submission fail
Date: Sun, 4 Apr 2021 11:45:59 +0100	[thread overview]
Message-ID: <600acb5f-d8a0-4589-29ae-3e8a517fcb7e@gmail.com> (raw)
In-Reply-To: <bfc0ffac5d54adeb3472ec6160f6aeaf8f70c1ca.1617099951.git.asml.silence@gmail.com>

On 30/03/2021 11:26, Pavel Begunkov wrote:
> Check that CQEs of a link comes in the order of submission, even when
> a link fails early during submission initial prep.

up

> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>  test/link.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
> 
> diff --git a/test/link.c b/test/link.c
> index c89d6b2..fadd0b5 100644
> --- a/test/link.c
> +++ b/test/link.c
> @@ -429,6 +429,53 @@ err:
>  	return 1;
>  }
>  
> +static int test_link_fail_ordering(struct io_uring *ring)
> +{
> +	struct io_uring_cqe *cqe;
> +	struct io_uring_sqe *sqe;
> +	int ret, i, nr_compl;
> +
> +	sqe = io_uring_get_sqe(ring);
> +	io_uring_prep_nop(sqe);
> +	sqe->flags |= IOSQE_IO_LINK;
> +	sqe->user_data = 0;
> +
> +	sqe = io_uring_get_sqe(ring);
> +	io_uring_prep_write(sqe, -1, NULL, 100, 0);
> +	sqe->flags |= IOSQE_IO_LINK;
> +	sqe->user_data = 1;
> +
> +	sqe = io_uring_get_sqe(ring);
> +	io_uring_prep_nop(sqe);
> +	sqe->flags |= IOSQE_IO_LINK;
> +	sqe->user_data = 2;
> +
> +	nr_compl = ret = io_uring_submit(ring);
> +	/* at least the first nop should have been submitted */
> +	if (ret < 1) {
> +		fprintf(stderr, "sqe submit failed: %d\n", ret);
> +		goto err;
> +	}
> +
> +	for (i = 0; i < nr_compl; i++) {
> +		ret = io_uring_wait_cqe(ring, &cqe);
> +		if (ret) {
> +			fprintf(stderr, "wait completion %d\n", ret);
> +			goto err;
> +		}
> +		if (cqe->user_data != i) {
> +			fprintf(stderr, "wrong CQE order, got %i, expected %i\n",
> +					(int)cqe->user_data, i);
> +			goto err;
> +		}
> +		io_uring_cqe_seen(ring, cqe);
> +	}
> +
> +	return 0;
> +err:
> +	return 1;
> +}
> +
>  int main(int argc, char *argv[])
>  {
>  	struct io_uring ring, poll_ring;
> @@ -492,5 +539,11 @@ int main(int argc, char *argv[])
>  		return ret;
>  	}
>  
> +	ret = test_link_fail_ordering(&ring);
> +	if (ret) {
> +		fprintf(stderr, "test_link_fail_ordering last failed\n");
> +		return ret;
> +	}
> +
>  	return 0;
>  }
> 

-- 
Pavel Begunkov

  reply	other threads:[~2021-04-04 10:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 10:26 [PATCH liburing] tests: test CQE ordering on early submission fail Pavel Begunkov
2021-04-04 10:45 ` Pavel Begunkov [this message]
2021-04-04 15:45 ` 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=600acb5f-d8a0-4589-29ae-3e8a517fcb7e@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /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 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.