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@xxxxxxxxxx> > cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> > cc: "David S. Miller" <davem@xxxxxxxxxxxxx> > cc: Eric Dumazet <edumazet@xxxxxxxxxx> > cc: Jakub Kicinski <kuba@xxxxxxxxxx> > cc: Paolo Abeni <pabeni@xxxxxxxxxx> > cc: Jens Axboe <axboe@xxxxxxxxx> > cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> > cc: linux-crypto@xxxxxxxxxxxxxxx > cc: netdev@xxxxxxxxxxxxxxx > --- > 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