All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Marcelo Diop-Gonzalez <marcelo827@gmail.com>
Cc: asml.silence@gmail.com, io-uring@vger.kernel.org
Subject: Re: [PATCH v4 0/1] io_uring: fix skipping of old timeout events
Date: Fri, 15 Jan 2021 11:38:44 -0700	[thread overview]
Message-ID: <3da76f2e-4941-206d-8881-9452bfce5980@kernel.dk> (raw)
In-Reply-To: <20210115183148.GA14438@marcelo-debian.domain>

On 1/15/21 11:31 AM, Marcelo Diop-Gonzalez wrote:
> On Fri, Jan 15, 2021 at 10:02:12AM -0700, Jens Axboe wrote:
>> On 1/15/21 9:54 AM, Marcelo Diop-Gonzalez wrote:
>>> This patch tries to fix a problem with IORING_OP_TIMEOUT events
>>> not being flushed if they should already have expired. The test below
>>> hangs before this change (unless you run with $ ./a.out ~/somefile 1):
>>>
>>> #include <fcntl.h>
>>> #include <stdio.h>
>>> #include <stdlib.h>
>>> #include <string.h>
>>> #include <unistd.h>
>>>
>>> #include <liburing.h>
>>>
>>> int main(int argc, char **argv) {
>>> 	if (argc < 2)
>>> 		return 1;
>>>
>>> 	int fd = open(argv[1], O_RDONLY);
>>> 	if (fd < 0) {
>>> 		perror("open");
>>> 		return 1;
>>> 	}
>>>
>>> 	struct io_uring ring;
>>> 	io_uring_queue_init(4, &ring, 0);
>>>
>>> 	struct io_uring_sqe *sqe = io_uring_get_sqe(&ring);
>>>
>>> 	struct __kernel_timespec ts = { .tv_sec = 9999999 };
>>> 	io_uring_prep_timeout(sqe, &ts, 1, 0);
>>> 	sqe->user_data = 123;
>>> 	int ret = io_uring_submit(&ring);
>>> 	if (ret < 0) {
>>> 		fprintf(stderr, "submit(timeout_sqe): %d\n", ret);
>>> 		return 1;
>>> 	}
>>>
>>> 	int n = 2;
>>> 	if (argc > 2)
>>> 		n = atoi(argv[2]);
>>>
>>> 	char buf;
>>> 	for (int i = 0; i < n; i++) {
>>> 		sqe = io_uring_get_sqe(&ring);
>>> 		if (!sqe) {
>>> 			fprintf(stderr, "too many\n");
>>> 			exit(1);
>>> 		}
>>> 		io_uring_prep_read(sqe, fd, &buf, 1, 0);
>>> 	}
>>> 	ret = io_uring_submit(&ring);
>>> 	if (ret < 0) {
>>> 		fprintf(stderr, "submit(read_sqe): %d\n", ret);
>>> 		exit(1);
>>> 	}
>>>
>>> 	struct io_uring_cqe *cqe;
>>> 	for (int i = 0; i < n+1; i++) {
>>> 		struct io_uring_cqe *cqe;
>>> 		int ret = io_uring_wait_cqe(&ring, &cqe);
>>> 		if (ret < 0) {
>>> 			fprintf(stderr, "wait_cqe(): %d\n", ret);
>>> 			return 1;
>>> 		}
>>> 		if (cqe->user_data == 123)
>>> 			printf("timeout found\n");
>>> 		io_uring_cqe_seen(&ring, cqe);
>>> 	}
>>> }
>>
>> Can you turn this into a test case for liburing? I'll apply the
>> associated patch, thanks (and to Pavel for review as well).
> 
> Yup, can do. I'll try to clean it up some first (especially so it
> doesn't just hang when it fails :/)

That'd of course be nice, but not a hard requirement. A lot of the
regressions tests will crash a broken kernel, so...

-- 
Jens Axboe


  reply	other threads:[~2021-01-15 18:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 16:54 [PATCH v4 0/1] io_uring: fix skipping of old timeout events Marcelo Diop-Gonzalez
2021-01-15 16:54 ` [PATCH v4 1/1] io_uring: flush timeouts that should already have expired Marcelo Diop-Gonzalez
2021-01-15 17:02 ` [PATCH v4 0/1] io_uring: fix skipping of old timeout events Jens Axboe
2021-01-15 18:31   ` Marcelo Diop-Gonzalez
2021-01-15 18:38     ` Jens Axboe [this message]
2021-01-15 18:48       ` Pavel Begunkov
2021-01-15 22:15         ` Marcelo Diop-Gonzalez

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=3da76f2e-4941-206d-8881-9452bfce5980@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=marcelo827@gmail.com \
    /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.