io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Josef <josef.grieb@gmail.com>,
	Pavel Begunkov <asml.silence@gmail.com>,
	io-uring@vger.kernel.org
Cc: norman@apache.org
Subject: Re: io_uring process termination/killing is not working
Date: Sat, 15 Aug 2020 18:21:05 -0700	[thread overview]
Message-ID: <63b47134-ad9c-4305-3a19-8c5deb7da686@kernel.dk> (raw)
In-Reply-To: <390e6d95-040b-404e-58c4-d633d6d0041d@kernel.dk>

On 8/15/20 5:41 PM, Jens Axboe wrote:
> On 8/15/20 5:36 PM, Josef wrote:
>>> Please try:
>>>
>>> https://git.kernel.dk/cgit/linux-block/commit/?h=io_uring-5.9&id=41d3344604e80db0e466f9deca5262b0914e4827
>>>
>>> There was a bug with the -EAGAIN doing repeated retries on sockets that
>>> are marked non-blocking.
>>>
>>
>> no it's not working, however I received the read event after
>> the second request (instead of the third request before) via Telnet
> 
> Are you sure your code is correct? I haven't looked too closely, but it
> doesn't look very solid. There's no error checking, and you seem to be
> setting up two rings (one overwriting the other). FWIW, I get the same
> behavior on 5.7-stable and the above branch, except that the 5.7 hangs
> on exit due to the other bug you found and that is fixed in the 5.9
> branch.
> 
> I'll take a closer look later or tomorrow, but just want to make sure
> I'm not spending time debugging your program :)
> 
> Hence it'd be helpful if you explain what your expectations are of
> the program, and how that differs from how it behaves.

Took a closer look, and made a few tweaks. Got rid of the extra links
and the nop, and I added a poll+read resubmit when a read completes.
Not sure how your program could work without that, if you expect it
to continue to echo out what is written on the connection? Also killed
that extra ring init.

After that, I made the following tweak to return short reads when
the the file is non-blocking. Then it seems to work as expected
for me.


diff --git a/fs/io_uring.c b/fs/io_uring.c
index cd956526c74c..dc506b75659c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3197,7 +3197,8 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 	}
 
 	/* read it all, or we did blocking attempt. no retry. */
-	if (!iov_iter_count(iter) || !force_nonblock)
+	if (!iov_iter_count(iter) || !force_nonblock ||
+	    (req->file->f_flags & O_NONBLOCK))
 		goto done;
 
 	io_size -= ret;

-- 
Jens Axboe


  reply	other threads:[~2020-08-16  1:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 17:58 io_uring process termination/killing is not working Josef
2020-08-12 18:05 ` Jens Axboe
2020-08-12 18:20   ` Pavel Begunkov
2020-08-12 18:22     ` Pavel Begunkov
2020-08-12 18:28       ` Pavel Begunkov
2020-08-12 23:32         ` Jens Axboe
2020-08-13 16:07           ` Josef
2020-08-13 16:09             ` Jens Axboe
2020-08-15  7:45           ` Pavel Begunkov
2020-08-15 15:12             ` Jens Axboe
2020-08-15 16:48               ` Pavel Begunkov
2020-08-15 21:43                 ` Josef
2020-08-15 22:35                   ` Jens Axboe
2020-08-15 23:21                     ` Josef
2020-08-15 23:31                     ` Jens Axboe
2020-08-16  0:36                       ` Josef
2020-08-16  0:41                         ` Jens Axboe
2020-08-16  1:21                           ` Jens Axboe [this message]
2020-08-16  3:14                             ` Josef
2020-08-16  3:20                               ` Jens Axboe
2020-08-16 17:30                                 ` Jens Axboe
2020-08-16 21:09                                   ` Josef
2020-08-16 22:17                                     ` Jens Axboe
2020-08-17  8:58                                       ` Josef
2020-08-17 10:08                                         ` Pavel Begunkov
2020-08-16 13:45                 ` Jens Axboe
2020-08-16 14:53                   ` Jens Axboe
2020-08-16 15:22                     ` Jens Axboe
2020-08-17 10:16                       ` Pavel Begunkov

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=63b47134-ad9c-4305-3a19-8c5deb7da686@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=josef.grieb@gmail.com \
    --cc=norman@apache.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).