liburing: send-zerocopy and linked timeout: how to deal buffer when timeout?

prepare to upgrade our diskless server to use send-zerocopy

send sqe linked with a timeout sqe to detect network problem, linked-timeout will return ETIME when something happen, at this point, how to deal the buffer passed in by ...sendzc() ? can it just be released as regular socket program? or is it still locked(maybe?) by somewhere in kernel stack ?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 34 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Never rely on a kernel version check. Either just try and the command and see if it fails, or use io_uring_get_probe() and check if that opcode is marked as supported.

Perfect, can I add your tested-by tag?

yes, very glad of this.

finally found it in io_read(), if there is no retry, currently only passed the last ret of io_iter_do_read to kiocb_done then failed in __io_complete_rw_common() because ret != cqe.res, it should be the total amount of all io_iter_do_read got. and only increase io->bytes_done when there is retry.

cqe.res stores the numbers of bytes we’re currently trying to do, so how about this?

diff --git a/io_uring/rw.c b/io_uring/rw.c
index 76ebcfebc9a6..c562203d7a67 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -823,6 +823,7 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
 			return -EAGAIN;
 		}
 
+		req->cqe.res = iov_iter_count(&s->iter);
 		/*
 		 * Now retry read with the IOCB_WAITQ parts set in the iocb. If
 		 * we get -EIOCBQUEUED, then we'll get a notification when the

I also pushed to a branch with an explanation for convenience.

https://github.com/isilence/linux/commit/9a70c235e440f48b10a8903ef95d2c9bbd7ff0b3

edit: branch https://github.com/isilence/linux.git rw-link-break

Thanks, I’ve updated the commit and also included a link to this issue.

changed to io_uring_get_probe() to check sendzc support, thanks to Jens will testing new api with 6.0-rc4 this week, and will check is there any performance lost with linked-timeout.

–

for the abnormal ECANCELED, uploaded the testing program.

Not entirely sure I get it, what do you mean by “happend with or without 3)”? Or maybe you have a simple reproducer?

this happened when submit 2 SQEs (read/send) or 3 SQEs(read/send/timeout). output of testing server:

[DEVEL-10:~/.../uring/tests]# make s && ./server /dev/sda
gcc -g server.c -o server -l uring
 ++ image size = 250059350016
STARTING IO_URING....
 ++ client-accepted: 6
     !! unexpected ECANCELED at   1 / 12413 !!
        resp-data: err=-125

in server.c, sending_timeout set to 1 to include timeout, 0 excluded. tested on 5.19.5.

issue-643-v1.zip