From: Paolo Abeni <pabeni@redhat.com>
To: David Howells <dhowells@redhat.com>
Cc: netdev@vger.kernel.org, "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>,
Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>, Jeff Layton <jlayton@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Chuck Lever III <chuck.lever@oracle.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH net-next v7 03/16] net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES
Date: Thu, 18 May 2023 12:25:13 +0200 [thread overview]
Message-ID: <47caea363e844bf716867c6a128d374cae4a5772.camel@redhat.com> (raw)
In-Reply-To: <1347187.1684403608@warthog.procyon.org.uk>
On Thu, 2023-05-18 at 10:53 +0100, David Howells wrote:
> Paolo Abeni <pabeni@redhat.com> wrote:
>
> > Minor nit: please respect the reverse x-mas tree order (there are a few
> > other occurrences around)
>
> I hadn't come across that. Normally I only apply that to the types so that
> the names aren't all over the place. But whatever.
>
> > > + if (space == 0 &&
> > > + !skb_can_coalesce(skb, skb_shinfo(skb)->nr_frags,
> > > + pages[0], off)) {
> > > + iov_iter_revert(iter, len);
> > > + break;
> > > + }
> >
> > It looks like the above condition/checks duplicate what the later
> > skb_append_pagefrags() will perform below. I guess the above chunk
> > could be removed?
>
> Good point. There used to be an allocation between in the case sendpage_ok()
> failed and we wanted to copy the data. I've removed that for the moment.
>
> > > + ret = -EIO;
> > > + if (!sendpage_ok(page))
> > > + goto out;
> >
> > My (limited) understanding is that the current sendpage code assumes
> > that the caller provides/uses pages suitable for such use. The existing
> > sendpage_ok() check is in place as way to try to catch possible code
> > bug - via the WARN_ONCE().
> >
> > I think the same could be done here?
>
> Yeah.
>
> Okay, I made the attached changes to this patch.
>
> David
> ---
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 56d629ea2f3d..f4a5b51aed22 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -6923,10 +6923,10 @@ static void skb_splice_csum_page(struct sk_buff *skb, struct page *page,
> ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
> ssize_t maxsize, gfp_t gfp)
> {
> + size_t frag_limit = READ_ONCE(sysctl_max_skb_frags);
> struct page *pages[8], **ppages = pages;
> - unsigned int i;
> ssize_t spliced = 0, ret = 0;
> - size_t frag_limit = READ_ONCE(sysctl_max_skb_frags);
> + unsigned int i;
>
> while (iter->count > 0) {
> ssize_t space, nr;
> @@ -6946,20 +6946,13 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
> break;
> }
>
> - if (space == 0 &&
> - !skb_can_coalesce(skb, skb_shinfo(skb)->nr_frags,
> - pages[0], off)) {
> - iov_iter_revert(iter, len);
> - break;
> - }
> -
> i = 0;
> do {
> struct page *page = pages[i++];
> size_t part = min_t(size_t, PAGE_SIZE - off, len);
>
> ret = -EIO;
> - if (!sendpage_ok(page))
> + if (WARN_ON_ONCE(!sendpage_ok(page)))
FWIS the current TCP code also has a 'IS_ENABLED(CONFIG_DEBUG_VM) &&'
guard, but I guess the plain WARN_ON_ONCE should be ok.
Side node: we need the whole series alltogether, you need to repost
even the unmodified patches.
Thanks!
Paolo
next prev parent reply other threads:[~2023-05-18 10:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 9:33 [PATCH net-next v7 00/16] splice, net: Replace sendpage with sendmsg(MSG_SPLICE_PAGES), part 1 David Howells
2023-05-15 9:33 ` [PATCH net-next v7 01/16] net: Declare MSG_SPLICE_PAGES internal sendmsg() flag David Howells
2023-05-15 9:33 ` [PATCH net-next v7 02/16] net: Pass max frags into skb_append_pagefrags() David Howells
2023-05-15 9:33 ` [PATCH net-next v7 03/16] net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES David Howells
2023-05-18 8:28 ` Paolo Abeni
2023-05-18 9:53 ` David Howells
2023-05-18 10:25 ` Paolo Abeni [this message]
2023-05-18 10:32 ` David Howells
2023-05-18 11:10 ` Paolo Abeni
2023-05-18 11:34 ` David Howells
2023-05-15 9:33 ` [PATCH net-next v7 04/16] tcp: Support MSG_SPLICE_PAGES David Howells
2023-05-15 9:33 ` [PATCH net-next v7 05/16] tcp: Convert do_tcp_sendpages() to use MSG_SPLICE_PAGES David Howells
2023-05-15 9:33 ` [PATCH net-next v7 06/16] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg David Howells
2023-05-15 9:33 ` [PATCH net-next v7 07/16] espintcp: Inline do_tcp_sendpages() David Howells
2023-05-15 9:33 ` [PATCH net-next v7 08/16] tls: " David Howells
2023-05-15 9:33 ` [PATCH net-next v7 09/16] siw: " David Howells
2023-05-15 9:33 ` [PATCH net-next v7 10/16] tcp: Fold do_tcp_sendpages() into tcp_sendpage_locked() David Howells
2023-05-15 9:33 ` [PATCH net-next v7 11/16] ip, udp: Support MSG_SPLICE_PAGES David Howells
2023-05-15 9:33 ` [PATCH net-next v7 12/16] ip6, udp6: " David Howells
2023-05-15 9:33 ` [PATCH net-next v7 13/16] udp: Convert udp_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-05-15 9:33 ` [PATCH net-next v7 14/16] ip: Remove ip_append_page() David Howells
2023-05-15 9:33 ` [PATCH net-next v7 15/16] af_unix: Support MSG_SPLICE_PAGES David Howells
2023-05-15 9:33 ` [PATCH net-next v7 16/16] unix: Convert udp_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-05-18 9:56 ` [PATCH net-next v8 03/16] net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES 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=47caea363e844bf716867c6a128d374cae4a5772.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=hch@infradead.org \
--cc=jlayton@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox