All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: David Howells <dhowells@redhat.com>, netdev@vger.kernel.org
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	David Ahern <dsahern@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-crypto@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 08/10] crypto: af_alg: Support MSG_SPLICE_PAGES
Date: Thu, 01 Jun 2023 11:49:15 +0200	[thread overview]
Message-ID: <bd2750e52b47af1782233e254114eb8d627f1073.camel@redhat.com> (raw)
In-Reply-To: <20230530141635.136968-9-dhowells@redhat.com>

On Tue, 2023-05-30 at 15:16 +0100, David Howells wrote:
> Make AF_ALG sendmsg() support MSG_SPLICE_PAGES.  This causes pages to be
> spliced from the source iterator.
> 
> This allows ->sendpage() to be replaced by something that can handle
> multiple multipage folios in a single transaction.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Herbert Xu <herbert@gondor.apana.org.au>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Eric Dumazet <edumazet@google.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Matthew Wilcox <willy@infradead.org>
> cc: linux-crypto@vger.kernel.org
> cc: netdev@vger.kernel.org
> ---
>  crypto/af_alg.c         | 28 ++++++++++++++++++++++++++--
>  crypto/algif_aead.c     | 22 +++++++++++-----------
>  crypto/algif_skcipher.c |  8 ++++----
>  3 files changed, 41 insertions(+), 17 deletions(-)
> 
> diff --git a/crypto/af_alg.c b/crypto/af_alg.c
> index fd56ccff6fed..62f4205d42e3 100644
> --- a/crypto/af_alg.c
> +++ b/crypto/af_alg.c
> @@ -940,6 +940,10 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
>  	bool init = false;
>  	int err = 0;
>  
> +	if ((msg->msg_flags & MSG_SPLICE_PAGES) &&
> +	    !iov_iter_is_bvec(&msg->msg_iter))
> +		return -EINVAL;
> +
>  	if (msg->msg_controllen) {
>  		err = af_alg_cmsg_send(msg, &con);
>  		if (err)
> @@ -985,7 +989,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
>  	while (size) {
>  		struct scatterlist *sg;
>  		size_t len = size;
> -		size_t plen;
> +		ssize_t plen;
>  
>  		/* use the existing memory in an allocated page */
>  		if (ctx->merge) {
> @@ -1030,7 +1034,27 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
>  		if (sgl->cur)
>  			sg_unmark_end(sg + sgl->cur - 1);
>  
> -		if (1 /* TODO check MSG_SPLICE_PAGES */) {
> +		if (msg->msg_flags & MSG_SPLICE_PAGES) {
> +			struct sg_table sgtable = {
> +				.sgl		= sg,
> +				.nents		= sgl->cur,
> +				.orig_nents	= sgl->cur,
> +			};
> +
> +			plen = extract_iter_to_sg(&msg->msg_iter, len, &sgtable,
> +						  MAX_SGL_ENTS, 0);

It looks like the above expect/supports only ITER_BVEC iterators, what
about adding a WARN_ON_ONCE(<other iov type>)?

Also, I'm keeping this series a bit more in pw to allow Herbert or
others to have a look.

Cheers,

Paolo


  reply	other threads:[~2023-06-01  9:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 14:16 [PATCH net-next v2 00/10] crypto, splice, net: Make AF_ALG handle sendmsg(MSG_SPLICE_PAGES) David Howells
2023-05-30 14:16 ` [PATCH net-next v2 01/10] Drop the netfs_ prefix from netfs_extract_iter_to_sg() David Howells
2023-06-06  9:00   ` Paolo Abeni
2023-05-30 14:16 ` [PATCH net-next v2 02/10] Fix a couple of spelling mistakes David Howells
2023-05-30 19:55   ` Simon Horman
2023-05-30 14:16 ` [PATCH net-next v2 03/10] Wrap lines at 80 David Howells
2023-05-30 14:16 ` [PATCH net-next v2 04/10] Move netfs_extract_iter_to_sg() to lib/scatterlist.c David Howells
2023-05-30 14:16 ` [PATCH net-next v2 05/10] crypto: af_alg: Pin pages rather than ref'ing if appropriate David Howells
2023-05-30 14:16 ` [PATCH net-next v2 06/10] crypto: af_alg: Use extract_iter_to_sg() to create scatterlists David Howells
2023-05-30 14:16 ` [PATCH net-next v2 07/10] crypto: af_alg: Indent the loop in af_alg_sendmsg() David Howells
2023-05-30 14:16 ` [PATCH net-next v2 08/10] crypto: af_alg: Support MSG_SPLICE_PAGES David Howells
2023-06-01  9:49   ` Paolo Abeni [this message]
2023-06-01 11:35   ` David Howells
2023-06-06  8:32     ` Paolo Abeni
2023-05-30 14:16 ` [PATCH net-next v2 09/10] crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-05-30 14:16 ` [PATCH net-next v2 10/10] crypto: af_alg/hash: Support MSG_SPLICE_PAGES David Howells
2023-06-06  8:43   ` Herbert Xu
2023-06-06  9:24   ` David Howells
2023-06-06  9:30     ` Herbert Xu
2023-06-06 10:08     ` David Howells

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=bd2750e52b47af1782233e254114eb8d627f1073.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=willy@infradead.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 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.