]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
splice: do not checksum AF_UNIX sockets
authorFrederik Deweerdt <deweerdt.lkml@gmail.com>
Tue, 10 Dec 2024 05:06:48 +0000 (21:06 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 Dec 2024 04:22:41 +0000 (20:22 -0800)
When `skb_splice_from_iter` was introduced, it inadvertently added
checksumming for AF_UNIX sockets. This resulted in significant
slowdowns, for example when using sendfile over unix sockets.

Using the test code in [1] in my test setup (2G single core qemu),
the client receives a 1000M file in:
- without the patch: 1482ms (+/- 36ms)
- with the patch: 652.5ms (+/- 22.9ms)

This commit addresses the issue by marking checksumming as unnecessary in
`unix_stream_sendmsg`

Cc: stable@vger.kernel.org
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")
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/Z1fMaHkRf8cfubuE@xiberoa
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/unix/af_unix.c

index 001ccc55ef0f936c935391549a1704dbd24bf021..6b176230044397c5dfea86d1b39365d17144b3f0 100644 (file)
@@ -2313,6 +2313,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
                fds_sent = true;
 
                if (unlikely(msg->msg_flags & MSG_SPLICE_PAGES)) {
+                       skb->ip_summed = CHECKSUM_UNNECESSARY;
                        err = skb_splice_from_iter(skb, &msg->msg_iter, size,
                                                   sk->sk_allocation);
                        if (err < 0) {