All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/3] io_uring: Add sendto(2) and recvfrom(2) support
@ 2021-12-30  1:35 Ammar Faizi
  2021-12-30  1:35 ` [RFC PATCH v1 1/3] io_uring: Rename `io_{send,recv}` to `io_{sendto,recvfrom}` Ammar Faizi
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ammar Faizi @ 2021-12-30  1:35 UTC (permalink / raw)
  To: Jens Axboe
  Cc: io-uring Mailing List, Pavel Begunkov, David S . Miller,
	Jakub Kicinski, netdev, linux-kernel, Ammar Faizi

Hello,

This RFC patchset adds sendto(2) and recvfrom(2) support for io_uring.
It also addresses an issue in the liburing GitHub repository [1].


## Motivations:
1) By using `sendto()` and `recvfrom()` we can make the submission
   simpler compared to always using `sendmsg()` and `recvmsg()` from
   the userspace.

2) There is a historical patch that tried to add the same
   functionality, but did not end up being applied. [2]

On Tue, 7 Jul 2020 12:29:18 -0600, Jens Axboe <axboe@kernel.dk> wrote:
> In a private conversation with the author, a good point was brought
> up that the sendto/recvfrom do not require an allocation of an async
> context, if we need to defer or go async with the request. I think
> that's a major win, to be honest. There are other benefits as well
> (like shorter path), but to me, the async less part is nice and will
> reduce overhead


## Changes summary
There are 3 patches in this series.

PATCH 1/3 renames io_recv to io_recvfrom and io_send to io_sendto.
Note that

    send(sockfd, buf, len, flags);

  is equivalent to

    sendto(sockfd, buf, len, flags, NULL, 0);

and
    recv(sockfd, buf, len, flags);

  is equivalent to

    recvfrom(sockfd, buf, len, flags, NULL, NULL);

So it is saner to have `send` and `recv` directed to `sendto` and
`recvfrom` instead of the opposite with respect to the name.


PATCH 2/3 makes `move_addr_to_user()` be a non static function. This
function lives in net/socket.c, we need to call this from io_uring
to add `recvfrom()` support for liburing. Added net files maintainers
to the CC list.

PATCH 3/3 adds `sendto(2)` and `recvfrom(2)` support for io_uring.
Added two new opcodes: IORING_OP_SENDTO and IORING_OP_RECVFROM.

## How to test

This patchset is based on "for-next" branch commit:

  aafc6e6eba29c890b0031267fc37c43490447c81 ("Merge branch 'for-5.17/io_uring' into for-next")

It is also available in the Git repository at:

  https://github.com/ammarfaizi2/linux-block ammarfaizi2/linux-block/io_uring-recvfrom-sendto


I also added the liburing support and test. The liburing support is
based on "xattr-getdents64" branch commit:

  18d71076f6c97e1b25aa0e3b0e12a913ec4717fa ("src/include/liburing.h: style cleanups")

It is available in the Git repository at:

  https://github.com/ammarfaizi2/liburing sendto-recvfrom


Link: https://github.com/axboe/liburing/issues/397 [1]
Link: https://lore.kernel.org/io-uring/a2399c89-2c45-375c-7395-b5caf556ec3d@kernel.dk/ [2]
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Ammar Faizi <ammarfaizi2@gmail.com>
---
Ammar Faizi (3):
  io_uring: Rename `io_{send,recv}` to `io_{sendto,recvfrom}`
  net: Make `move_addr_to_user()` be a non static function
  io_uring: Add `sendto(2)` and `recvfrom(2)` support

 fs/io_uring.c                 | 88 +++++++++++++++++++++++++++++++----
 include/linux/socket.h        |  2 +
 include/uapi/linux/io_uring.h |  2 +
 net/socket.c                  |  4 +-
 4 files changed, 86 insertions(+), 10 deletions(-)


base-commit: aafc6e6eba29c890b0031267fc37c43490447c81
-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [RFC PATCH v1 1/3] io_uring: Rename `io_{send, recv}` to `io_{sendto, recvfrom}`
@ 2021-12-30 16:54 kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-12-30 16:54 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 5797 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211230013250.103267-1-ammar.faizi@intel.com>
References: <20211230013250.103267-1-ammar.faizi@intel.com>
TO: Ammar Faizi <ammarfaizi2@gmail.com>

Hi Ammar,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on aafc6e6eba29c890b0031267fc37c43490447c81]

url:    https://github.com/0day-ci/linux/commits/Ammar-Faizi/io_uring-Add-sendto-2-and-recvfrom-2-support/20211230-093703
base:   aafc6e6eba29c890b0031267fc37c43490447c81
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago
config: i386-randconfig-m021-20211230 (https://download.01.org/0day-ci/archive/20211231/202112310016.rALniPPT-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/io_uring.c:5550 io_recvfrom() error: uninitialized symbol 'flags'.

Old smatch warnings:
fs/io_uring.c:6364 io_timeout_cancel() warn: passing a valid pointer to 'PTR_ERR'
fs/io_uring.c:6421 io_timeout_update() warn: passing a valid pointer to 'PTR_ERR'
fs/io_uring.c:8722 io_sqe_files_register() error: we previously assumed 'ctx->file_data' could be null (see line 8694)

vim +/flags +5550 fs/io_uring.c

0fa03c624d8fc9 Jens Axboe        2019-04-19  5501  
9cfe685bad5431 Ammar Faizi       2021-12-30  5502  static int io_recvfrom(struct io_kiocb *req, unsigned int issue_flags)
fddafacee287b3 Jens Axboe        2020-01-04  5503  {
6b754c8b912a16 Pavel Begunkov    2020-07-16  5504  	struct io_buffer *kbuf;
fddafacee287b3 Jens Axboe        2020-01-04  5505  	struct io_sr_msg *sr = &req->sr_msg;
fddafacee287b3 Jens Axboe        2020-01-04  5506  	struct msghdr msg;
7a7cacba8b4560 Pavel Begunkov    2020-07-16  5507  	void __user *buf = sr->buf;
7a7cacba8b4560 Pavel Begunkov    2020-07-16  5508  	struct socket *sock;
fddafacee287b3 Jens Axboe        2020-01-04  5509  	struct iovec iov;
fddafacee287b3 Jens Axboe        2020-01-04  5510  	unsigned flags;
d1fd1c201d7507 Pavel Begunkov    2021-12-05  5511  	int ret, min_ret = 0;
45d189c6062922 Pavel Begunkov    2021-02-10  5512  	bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
7a7cacba8b4560 Pavel Begunkov    2020-07-16  5513  
dba4a9256bb4d7 Florent Revest    2020-12-04  5514  	sock = sock_from_file(req->file);
7a7cacba8b4560 Pavel Begunkov    2020-07-16  5515  	if (unlikely(!sock))
dba4a9256bb4d7 Florent Revest    2020-12-04  5516  		return -ENOTSOCK;
fddafacee287b3 Jens Axboe        2020-01-04  5517  
bc02ef3325e3ef Pavel Begunkov    2020-07-16  5518  	if (req->flags & REQ_F_BUFFER_SELECT) {
51aac424aef980 Pavel Begunkov    2021-10-14  5519  		kbuf = io_recv_buffer_select(req, issue_flags);
bcda7baaa3f15c Jens Axboe        2020-02-23  5520  		if (IS_ERR(kbuf))
bcda7baaa3f15c Jens Axboe        2020-02-23  5521  			return PTR_ERR(kbuf);
bcda7baaa3f15c Jens Axboe        2020-02-23  5522  		buf = u64_to_user_ptr(kbuf->addr);
bcda7baaa3f15c Jens Axboe        2020-02-23  5523  	}
fddafacee287b3 Jens Axboe        2020-01-04  5524  
7a7cacba8b4560 Pavel Begunkov    2020-07-16  5525  	ret = import_single_range(READ, buf, sr->len, &iov, &msg.msg_iter);
14c32eee928662 Pavel Begunkov    2020-07-16  5526  	if (unlikely(ret))
14c32eee928662 Pavel Begunkov    2020-07-16  5527  		goto out_free;
fddafacee287b3 Jens Axboe        2020-01-04  5528  
fddafacee287b3 Jens Axboe        2020-01-04  5529  	msg.msg_name = NULL;
fddafacee287b3 Jens Axboe        2020-01-04  5530  	msg.msg_control = NULL;
fddafacee287b3 Jens Axboe        2020-01-04  5531  	msg.msg_controllen = 0;
fddafacee287b3 Jens Axboe        2020-01-04  5532  	msg.msg_namelen = 0;
fddafacee287b3 Jens Axboe        2020-01-04  5533  	msg.msg_iocb = NULL;
fddafacee287b3 Jens Axboe        2020-01-04  5534  	msg.msg_flags = 0;
fddafacee287b3 Jens Axboe        2020-01-04  5535  
044118069a23fd Pavel Begunkov    2021-04-01  5536  	flags = req->sr_msg.msg_flags;
044118069a23fd Pavel Begunkov    2021-04-01  5537  	if (force_nonblock)
fddafacee287b3 Jens Axboe        2020-01-04  5538  		flags |= MSG_DONTWAIT;
0031275d119efe Stefan Metzmacher 2021-03-20  5539  	if (flags & MSG_WAITALL)
0031275d119efe Stefan Metzmacher 2021-03-20  5540  		min_ret = iov_iter_count(&msg.msg_iter);
0031275d119efe Stefan Metzmacher 2021-03-20  5541  
0b7b21e42ba2d6 Jens Axboe        2020-01-31  5542  	ret = sock_recvmsg(sock, &msg, flags);
7297ce3d59449d Pavel Begunkov    2021-11-23  5543  out_free:
7297ce3d59449d Pavel Begunkov    2021-11-23  5544  	if (ret < min_ret) {
7297ce3d59449d Pavel Begunkov    2021-11-23  5545  		if (ret == -EAGAIN && force_nonblock)
fddafacee287b3 Jens Axboe        2020-01-04  5546  			return -EAGAIN;
fddafacee287b3 Jens Axboe        2020-01-04  5547  		if (ret == -ERESTARTSYS)
fddafacee287b3 Jens Axboe        2020-01-04  5548  			ret = -EINTR;
7297ce3d59449d Pavel Begunkov    2021-11-23  5549  		req_set_fail(req);
7297ce3d59449d Pavel Begunkov    2021-11-23 @5550  	} else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) {
7297ce3d59449d Pavel Begunkov    2021-11-23  5551  		req_set_fail(req);
7297ce3d59449d Pavel Begunkov    2021-11-23  5552  	}
d1fd1c201d7507 Pavel Begunkov    2021-12-05  5553  
d1fd1c201d7507 Pavel Begunkov    2021-12-05  5554  	__io_req_complete(req, issue_flags, ret, io_put_kbuf(req));
fddafacee287b3 Jens Axboe        2020-01-04  5555  	return 0;
fddafacee287b3 Jens Axboe        2020-01-04  5556  }
fddafacee287b3 Jens Axboe        2020-01-04  5557  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-01-07 11:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30  1:35 [RFC PATCH v1 0/3] io_uring: Add sendto(2) and recvfrom(2) support Ammar Faizi
2021-12-30  1:35 ` [RFC PATCH v1 1/3] io_uring: Rename `io_{send,recv}` to `io_{sendto,recvfrom}` Ammar Faizi
2021-12-30 11:59   ` [RFC PATCH v1 1/3] io_uring: Rename `io_{send, recv}` to `io_{sendto, recvfrom}` kernel test robot
2021-12-30  1:35 ` [RFC PATCH v1 2/3] net: Make `move_addr_to_user()` be a non static function Ammar Faizi
2021-12-30  1:35 ` [RFC PATCH v1 3/3] io_uring: Add `sendto(2)` and `recvfrom(2)` support Ammar Faizi
2021-12-30 12:00   ` [RFC PATCH v2 0/3] io_uring: Add sendto(2) and recvfrom(2) support Ammar Faizi
2021-12-30 12:00     ` [RFC PATCH v2 1/3] io_uring: Rename `io_{send,recv}` to `io_{sendto,recvfrom}` Ammar Faizi
2021-12-30 12:00     ` [RFC PATCH v2 2/3] net: Make `move_addr_to_user()` be a non static function Ammar Faizi
2021-12-30 12:00     ` [RFC PATCH v2 3/3] io_uring: Add `sendto(2)` and `recvfrom(2)` support Ammar Faizi
2021-12-30 17:52       ` [RFC PATCH v3 0/3] io_uring: Add sendto(2) and recvfrom(2) support Ammar Faizi
2021-12-30 17:52         ` [RFC PATCH v3 1/3] io_uring: Rename `io_{send,recv}` to `io_{sendto,recvfrom}` Ammar Faizi
2021-12-30 17:52         ` [RFC PATCH v3 2/3] net: Make `move_addr_to_user()` be a non static function Ammar Faizi
2021-12-30 17:52         ` [RFC PATCH v3 3/3] io_uring: Add `sendto(2)` and `recvfrom(2)` support Ammar Faizi
2022-01-06 17:31           ` Praveen Kumar
2022-01-06 20:38             ` Ammar Faizi
2022-01-06 20:48               ` Ammar Faizi
2022-01-07  8:33               ` Praveen Kumar
2022-01-07 11:02                 ` Ammar Faizi
2021-12-30 16:54 [RFC PATCH v1 1/3] io_uring: Rename `io_{send, recv}` to `io_{sendto, recvfrom}` kernel test robot

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.