All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: dhowells@redhat.com, netdev@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	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 10/10] crypto: af_alg/hash: Support MSG_SPLICE_PAGES
Date: Tue, 06 Jun 2023 10:24:55 +0100	[thread overview]
Message-ID: <1845449.1686043495@warthog.procyon.org.uk> (raw)
In-Reply-To: <ZH7xzYfwQoWZLUYa@gondor.apana.org.au>

Herbert Xu <herbert@gondor.apana.org.au> wrote:

> > -	if (limit > sk->sk_sndbuf)
> > -		limit = sk->sk_sndbuf;
> > +	/* Don't limit to ALG_MAX_PAGES if the pages are all already pinned. */
> > +	if (!user_backed_iter(&msg->msg_iter))
> > +		max_pages = INT_MAX;

If the iov_iter is a kernel-backed type (BVEC, KVEC, XARRAY) then (a) all the
pages it refers to must already be pinned in memory and (b) the caller must
have limited it in some way (splice is limited by the pipe capacity, for
instance).  In which case, it seems pointless taking more than one pass of the
while loop if we can avoid it - at least from the point of view of memory
handling; granted there might be other criteria such as hogging crypto offload
hardware.

> > +	else
> > +		max_pages = min_t(size_t, max_pages,
> > +				  DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE));
> 
> What's the purpose of relaxing this limit?

If the iov_iter is a user-backed type (IOVEC or UBUF) then it's not relaxed.
max_pages is ALG_MAX_PAGES here (actually, I should just move that here so
that it's clearer).

I am, however, applying the sk_sndbuf limit here also - there's no point
extracting more pages than we need to if ALG_MAX_PAGES of whole pages would
overrun the byte limit.

> Even if there is a reason for this shouldn't this be in a patch by itself?

I suppose I could do it as a follow-on patch; use ALG_MAX_PAGES and sk_sndbuf
before that as for user-backed iterators.

Actually, is it worth paying attention to sk_sndbuf for kernel-backed
iterators?

David


  parent reply	other threads:[~2023-06-06  9:25 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
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 [this message]
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=1845449.1686043495@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --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=pabeni@redhat.com \
    --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.