All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederik Deweerdt <deweerdt.lkml@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, dhowells@redhat.com
Subject: Re: [PATCH net] splice: do not checksum AF_UNIX sockets
Date: Fri, 29 Nov 2024 20:05:20 -0800	[thread overview]
Message-ID: <Z0qPALhaNORMG8Go@xiberoa> (raw)
In-Reply-To: <Z0ptqDcLjrjqruQA@pop-os.localdomain>

On Fri, Nov 29, 2024 at 05:43:04PM -0800, Cong Wang wrote:
> On Fri, Nov 29, 2024 at 03:20:14PM -0800, Frederik Deweerdt wrote:
> > When `skb_splice_from_iter` was introduced, it inadvertently added
> > checksumming for AF_UNIX sockets. This resulted in significant
> > slowdowns, as when using sendfile over unix sockets.
> > 
> > Using the test code [1] in my test setup (2G, single core x86_64 qemu),
> > the client receives a 1000M file in:
> > - without the patch: 1577ms (+/- 36.1ms)
> > - with the patch: 725ms (+/- 28.3ms)
> > 
> > This commit skips addresses the issue by skipping checksumming when
> > splice occurs a AF_UNIX socket.
> > 
> > [1] https://gist.github.com/deweerdt/a3ee2477d1d87524cf08618d3c179f06
> > 
> > Signed-off-by: Frederik Deweerdt <deweerdt.lkml@gmail.com>
> > Fixes: 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")
> > ---
> >  net/core/skbuff.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 6841e61a6bd0..49e4f9ab625f 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -7233,7 +7233,7 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
> >  				goto out;
> >  			}
> >  
> > -			if (skb->ip_summed == CHECKSUM_NONE)
> > +			if (skb->ip_summed == CHECKSUM_NONE && skb->sk->sk_family != AF_UNIX)
> 
> Are you sure it is always safe to dereferene skb->sk here? I am not sure
> about the KCM socket case.
> 
> Instead of checking skb->sk->sk_family, why not just pass an additional
> boolean parameter to this function?
> 
I saw that every caller was dereferrencing an `sk`, but you are right
that that a boolean would be safer.

I'll resend an updated version.

Thanks,
Frederik

  reply	other threads:[~2024-11-30  4:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29 23:20 [PATCH net] splice: do not checksum AF_UNIX sockets Frederik Deweerdt
2024-11-30  1:43 ` Cong Wang
2024-11-30  4:05   ` Frederik Deweerdt [this message]
2024-11-30 12:08   ` David Laight
2024-12-03 16:30 ` David Howells
2024-12-03 21:48   ` Cong Wang
2024-12-03 22:35     ` Frederik Deweerdt

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=Z0qPALhaNORMG8Go@xiberoa \
    --to=deweerdt.lkml@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /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.