Skip to contentSkip to conversation

tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path

PATCH Applied Talal Ahmad 2 participants 2 messages Jul 9, 2021

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

PATCH 1/1 tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path

From: Talal Ahmad <[email protected]>

sk_wmem_schedule makes sure that sk_forward_alloc has enough bytes for charging that is going to be done by sk_mem_charge.

In the transmit zerocopy path, there is sk_mem_charge but there was no call to sk_wmem_schedule. This change adds that call.

Without this call to sk_wmem_schedule, sk_forward_alloc can go negetive which is a bug because sk_forward_alloc is a per-socket space that has been forward charged so this can't be negative.

---
 net/ipv4/tcp.c | 3 +++
 1 file changed, 3 insertions(+)
net/ipv4/tcp.c +3 -0
index d5ab5f243640..8cb44040ec68 100644
@@ -1375,6 +1375,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
 			}
 			pfrag->offset += copy;
 		} else {
+			if (!sk_wmem_schedule(sk, copy))
+				goto wait_for_space;
+
 			err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg);
 			if (err == -EMSGSIZE || err == -EEXIST) {
 				tcp_mark_push(tp, skb);
Signature · 1 line
2.32.0.93.g670b81a890-goog
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 9 lines · On Fri, 9 Jul 2021 11:43:06 -0400 you wrote:

From: Talal Ahmad <[email protected]>

sk_wmem_schedule makes sure that sk_forward_alloc has enough bytes for charging that is going to be done by sk_mem_charge.

In the transmit zerocopy path, there is sk_mem_charge but there was no call to sk_wmem_schedule. This change adds that call.

[...]

Here is the summary with links:
- [net] tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path

    https://git.kernel.org/netdev/net/c/358ed6242070

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html