Received: by 10.223.176.46 with SMTP id f43csp2385866wra; Thu, 25 Jan 2018 09:03:50 -0800 (PST) X-Google-Smtp-Source: AH8x2244zctpzXhc1sAuaANSi3M0k7r7ZA5b4IXrukQ4Vr9728wRCoYkX88BNYNl2LcCPmNMz9MT X-Received: by 2002:a17:902:64d6:: with SMTP id y22-v6mr11954094pli.444.1516899830016; Thu, 25 Jan 2018 09:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516899829; cv=none; d=google.com; s=arc-20160816; b=Koctvp5SE/7DbstvbzA3wcS9UDqKw7bGfkoOYqxf7kwcBYTdAD0o/W6x8qV/GQtn0J d4ylzVwnujOZ3fmliUURcEN2l1lA6iP4jxRlJB24xAsRUSw3csQebf7xEI2gKnYw9SZr g1JqVgcKx2YKVoVSQiZgO5h8fmk5lzZR2ZTjkMtCsPbez6xRGyMMCgTKkTDpt5tStwet KjWNNYmvMpG+UJctqSNDqT6iEVzQEwJY+7ZJDF6JWGn+YZifvXL3BLhsw2FNhoqWrdOF B3p1qmVMAs/j1a2JfwKaPmx0tYxDffhDPr+AFbnT8f0iMBgK+X8jwJFxOQ/pDsfzj6VT Z0Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date :arc-authentication-results; bh=jo+MFEZ49yc5p7TTpaJU/o7Dw2ca/kQfd0dwQtoaveU=; b=GzvLFzpco1UqzIidt89mIo4zkuSevhFL6g37AJX6/cM7tF/DSNHGnaq0Y7M+3ptn8K 252JFUAlwkB9R+lQMhx/nosqoLa5u2Ix9iJXMUFNO0398rgNiMN2JOIkUiWZcGXn5XYl 11YgMpRXMKW2tA35uaswgDkkmEsoqcrBLT/DzhOrZtidHs5tAy3vo6rAAKo+bF6at6uZ 601sKjHQsQTjDV6oiYUvu6pyiyJhdfTnvxsPvh9EbyZary5H1p2TeaHEmUG+dSM2kAwt a24Qbh98uHO1uGzi7oSCi8Zf9EDJeovgXZpBeFrxt9PmVyFBA4GECfkYzanenFnR6/tG 0cmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k190si1779822pgk.395.2018.01.25.09.03.35; Thu, 25 Jan 2018 09:03:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbeAYRDG (ORCPT + 99 others); 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 Received: from localhost (67.110.78.66.ptr.us.xo.net [67.110.78.66]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 5AC9910916CA6; Thu, 25 Jan 2018 09:03:04 -0800 (PST) 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 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 25 Jan 2018 09:03:04 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk 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.