* [PATCH net] tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path
@ 2021-07-09 15:43 Talal Ahmad
2021-07-09 18:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Talal Ahmad @ 2021-07-09 15:43 UTC (permalink / raw)
To: David Miller
Cc: netdev, Talal Ahmad, Willem de Bruijn, Wei Wang,
Soheil Hassas Yeganeh, Eric Dumazet
From: Talal Ahmad <talalahmad@google.com>
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.
Fixes: f214f915e7db ("tcp: enable MSG_ZEROCOPY")
Signed-off-by: Talal Ahmad <talalahmad@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Wei Wang <weiwan@google.com>
Reviewed-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/tcp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index d5ab5f243640..8cb44040ec68 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -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);
--
2.32.0.93.g670b81a890-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path
2021-07-09 15:43 [PATCH net] tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path Talal Ahmad
@ 2021-07-09 18:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-09 18:30 UTC (permalink / raw)
To: Talal Ahmad; +Cc: davem, netdev, talalahmad, willemb, weiwan, soheil, edumazet
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Fri, 9 Jul 2021 11:43:06 -0400 you wrote:
> From: Talal Ahmad <talalahmad@google.com>
>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-09 18:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 15:43 [PATCH net] tcp: call sk_wmem_schedule before sk_mem_charge in zerocopy path Talal Ahmad
2021-07-09 18:30 ` patchwork-bot+netdevbpf
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.