Re: io_uring process termination/killing is not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux