Re: [PATCH 1/3] io_uring: Avoid msghdr on op_connect/op_bind async data

Jens Axboe <[email protected]>
Newsgroups org.kernel.vger.io-uring
Message-ID <[email protected]>
On 6/2/26 2:03 PM, Gabriel Krisman Bertazi wrote:
> Both IORING_OP_CONNECT and IORING_OP_BIND reuse the msghdr object for
> just to store sockaddr.  Beyond allocating a much larger object than
> needed, msghdr can also wrap an iovec, which will be recycled
> unnecessarily.  This splits the sockaddr into an async type.

Note: please prefix things that are net related as:

io_uring/net: Avoid msghdr on op_connect/op_bind async data

> diff --git a/io_uring/net.h b/io_uring/net.h
> index 51fda715d3c0..b296ec4eefb2 100644
> --- a/io_uring/net.h
> +++ b/io_uring/net.h
> @@ -5,6 +5,10 @@
>  #include <linux/io_uring_types.h>
>  #include <uapi/linux/io_uring/bpf_filter.h>
>  
> +struct io_async_sockaddr {
> +	struct sockaddr_storage		addr;
> +};
> +

Why not just use sockaddr_storage directly?

> diff --git a/io_uring/net.c b/io_uring/net.c
> index cceb5c1409ca..1da811100132 100644
> --- a/io_uring/net.c
> +++ b/io_uring/net.c
> @@ -1677,7 +1677,7 @@ void io_socket_bpf_populate(struct io_uring_bpf_ctx *bctx, struct io_kiocb *req)
>  void io_connect_bpf_populate(struct io_uring_bpf_ctx *bctx, struct io_kiocb *req)
>  {
>  	struct io_connect *conn = io_kiocb_to_cmd(req, struct io_connect);
> -	struct io_async_msghdr *iomsg = req->async_data;
> +	struct io_async_sockaddr *iomsg = req->async_data;
>  	struct sockaddr_storage *ss = &iomsg->addr;

and if we did that, then this line goes away and it just becomes:

	struct sockaddr_storage *ss = req->async_data;

instead?

Other than that, looks good to me, whole series in fact.

-- 
Jens Axboe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.