Re: [PATCH v4] memcg: add charging of already allocated slab objects

From: Vlastimil Babka
Date: Tue Sep 10 2024 - 05:19:44 EST


On 9/10/24 10:26, Paolo Abeni wrote:
> On 9/5/24 19:34, Shakeel Butt wrote:
>> * kmem_cache_alloc_node - Allocate an object on the specified node
>> * @s: The cache to allocate from.
>> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
>> index 64d07b842e73..3c13ca8c11fb 100644
>> --- a/net/ipv4/inet_connection_sock.c
>> +++ b/net/ipv4/inet_connection_sock.c
>> @@ -715,6 +715,7 @@ struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg)
>> release_sock(sk);
>> if (newsk && mem_cgroup_sockets_enabled) {
>> int amt = 0;
>> + gfp_t gfp = GFP_KERNEL | __GFP_NOFAIL;
>>
>> /* atomically get the memory usage, set and charge the
>> * newsk->sk_memcg.
>> @@ -731,8 +732,8 @@ struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg)
>> }
>>
>> if (amt)
>> - mem_cgroup_charge_skmem(newsk->sk_memcg, amt,
>> - GFP_KERNEL | __GFP_NOFAIL);
>> + mem_cgroup_charge_skmem(newsk->sk_memcg, amt, gfp);
>> + kmem_cache_charge(newsk, gfp);
>>
>> release_sock(newsk);
>> }
>
> The networking bits looks sane to me - with a very minor nit about the
> reverse xmas tree order in variables declaration above.
>
> Acked-by: Paolo Abeni <pabeni@xxxxxxxxxx>

Great, thanks, I will adjust the ordering.