From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751232AbeAYRDG (ORCPT ); Thu, 25 Jan 2018 12:03:06 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:59520 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbeAYRDF (ORCPT ); Thu, 25 Jan 2018 12:03:05 -0500 Date: Thu, 25 Jan 2018 12:03:02 -0500 (EST) Message-Id: <20180125.120302.1117695034222616751.davem@davemloft.net> To: guro@fb.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, edumazet@google.com, hannes@cmpxchg.org, tj@kernel.org Subject: Re: [PATCH net] net: memcontrol: charge allocated memory after mem_cgroup_sk_alloc() From: David Miller In-Reply-To: <20180125001911.15597-1-guro@fb.com> References: <20180125001911.15597-1-guro@fb.com> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Gushchin Date: Thu, 25 Jan 2018 00:19:11 +0000 > @@ -476,6 +477,10 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern) > spin_unlock_bh(&queue->fastopenq.lock); > } > mem_cgroup_sk_alloc(newsk); > + amt = sk_memory_allocated(newsk); > + if (amt && newsk->sk_memcg) > + mem_cgroup_charge_skmem(newsk->sk_memcg, amt); > + This looks confusing to me. sk_memory_allocated() is the total amount of memory used by all sockets for a particular "struct proto", not just for that specific socket. Maybe I don't understand how this socket memcg stuff works, but it seems like you should be looking instead at how much memory is allocated to this specific socket. Thanks.