Skip to contentSkip to conversation

splice: do not checksum AF_UNIX sockets

PATCH Applied Frederik Deweerdt 5 participants 6 messages Dec 10, 2024 – Dec 12, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 splice: do not checksum AF_UNIX sockets

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

Fixes 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")
---
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)
net/unix/af_unix.c +1 -0
index 001ccc55ef0f..6b1762300443 100644
@@ -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) {
Signature · 1 line
2.44.1
Reviewed-by on v2 1/1
#1 lore raw

From: Frederik Deweerdt <[email protected]>
Date: Mon, 9 Dec 2024 21:06:48 -0800

Quoted 9 lines

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)

Quoted 7 lines

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

Fixes 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")

---

For the future submission, it would be nice to explain changes between versions and add the old patch link under '---' here.

The patch itself looks good to me.

Quoted 17 lines
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)
net/unix/af_unix.c +1 -0
index 001ccc55ef0f..6b1762300443 100644
@@ -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) {
Signature · 1 line
2.44.1
#2 lore raw
Quoted 14 lines · Kuniyuki Iwashima

From: Frederik Deweerdt <[email protected]>
Date: Mon, 9 Dec 2024 21:06:48 -0800

Quoted 12 lines

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

Quoted 8 lines
Quoted 4 lines
Fixes 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")

---

For the future submission, it would be nice to explain changes between versions and add the old patch link under '---' here.

Will do, thank you.

Quoted 4 lines

The patch itself looks good to me.

Thanks!
Frederik

Quoted 17 lines
Quoted 17 lines
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)
net/unix/af_unix.c +1 -0
index 001ccc55ef0f..6b1762300443 100644
@@ -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) {
Signature · 1 line
2.44.1
Reviewed-by on v2 1/1
#3 lore raw
In reply to Frederik Deweerdt
Quoted 10 lines · Frederik Deweerdt

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)

Quoted 7 lines

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

Fixes 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")

---

Reviewed-by on v2 1/1
#4 lore raw
In reply to Frederik Deweerdt
Quoted 12 lines · Frederik Deweerdt

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

Quoted 6 lines
Fixes 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")
---
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)
#5 lore raw
In reply to Frederik Deweerdt
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Mon, 9 Dec 2024 21:06:48 -0800 you wrote:

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)

[...]

Here is the summary with links:
- [v2,net] splice: do not checksum AF_UNIX sockets

    https://git.kernel.org/netdev/net/c/6bd8614fc2d0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html