* [PATCH net-next v2] inet: Cleanup on charging memory for newly accepted sockets
@ 2023-06-20 9:27 Abel Wu
2023-06-22 5:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Abel Wu @ 2023-06-20 9:27 UTC (permalink / raw)
To: David S. Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Abel Wu, open list:NETWORKING [IPv4/IPv6], open list
If there is no net-memcg associated with the sock, don't bother
calculating its memory usage for charge.
Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
---
net/ipv4/inet_connection_sock.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 65ad4251f6fd..22f7b3aaff3c 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -706,20 +706,23 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern)
out:
release_sock(sk);
if (newsk && mem_cgroup_sockets_enabled) {
- int amt;
+ int amt = 0;
/* atomically get the memory usage, set and charge the
* newsk->sk_memcg.
*/
lock_sock(newsk);
- /* The socket has not been accepted yet, no need to look at
- * newsk->sk_wmem_queued.
- */
- amt = sk_mem_pages(newsk->sk_forward_alloc +
- atomic_read(&newsk->sk_rmem_alloc));
mem_cgroup_sk_alloc(newsk);
- if (newsk->sk_memcg && amt)
+ if (newsk->sk_memcg) {
+ /* The socket has not been accepted yet, no need
+ * to look at newsk->sk_wmem_queued.
+ */
+ amt = sk_mem_pages(newsk->sk_forward_alloc +
+ atomic_read(&newsk->sk_rmem_alloc));
+ }
+
+ if (amt)
mem_cgroup_charge_skmem(newsk->sk_memcg, amt,
GFP_KERNEL | __GFP_NOFAIL);
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] inet: Cleanup on charging memory for newly accepted sockets
2023-06-20 9:27 [PATCH net-next v2] inet: Cleanup on charging memory for newly accepted sockets Abel Wu
@ 2023-06-22 5:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-22 5:50 UTC (permalink / raw)
To: Abel Wu; +Cc: davem, dsahern, edumazet, kuba, pabeni, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 20 Jun 2023 17:27:11 +0800 you wrote:
> If there is no net-memcg associated with the sock, don't bother
> calculating its memory usage for charge.
>
> Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
> ---
> net/ipv4/inet_connection_sock.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
Here is the summary with links:
- [net-next,v2] inet: Cleanup on charging memory for newly accepted sockets
https://git.kernel.org/netdev/net-next/c/53bf91641ae1
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:[~2023-06-22 5:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 9:27 [PATCH net-next v2] inet: Cleanup on charging memory for newly accepted sockets Abel Wu
2023-06-22 5:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).