Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1136964ybh; Tue, 10 Mar 2020 15:35:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vut5YcjNwKRgZVix3QekCB+VrqXDp8qF6yVyRWD5pjYgf5ftxw9xhKXyTBXHZlluiRenpcn X-Received: by 2002:a05:6830:22ce:: with SMTP id q14mr841otc.298.1583879720855; Tue, 10 Mar 2020 15:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583879720; cv=none; d=google.com; s=arc-20160816; b=wkAWaP9EkwBqw9WA7ci6gKSyLlFQTr1qzLRjEqznpALoSfMx+7MAVPCvV1HY5EWsQa 8Kg+uoKe/1suRWv3TCXSVggZfhiALcw+tW/UUspaHeuUgrOEWcjUOnDHcdcgE/nH8Epa qa3VYI/ovGtn/oARKdRai/DbPAFne3FtEgLqpbezthDjMRROnQ0IJKKevaFVMUlb2tbn 1Zl7RpcDgfG3Wn6gVoxTexT/aK6deUV1z2HjZdJJNnmAXktAv7lx2jcXuEvCB7sv4x4g Ri9CC1VFj8sUZOlCubsyDGx6RU53I/+P7O8Oi7DF1ESDWXLiBTBl8uTRKklvgzd7OEAJ Ekbg== 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; bh=cPYJpU2p+UYnqTE/NftLC2s9ebyO5cdICcK3PTEehB0=; b=ruE8OY1IM7e61JdkiV1xS+8o5ueo0ZSPQ9272dBnLnw9yLw1NqKS5aWW5kgYpdELJQ l4KS/Nd4r+2Nv+6ROGktGyorvOOtuHjgv/8APt9nLYc7DUMaEWLmHkN6RcIFv2XLurup 2Eir9OpNTqxlxkG6Zo47Zl+iSeYl1XyuBXI3L/dzvIGnmceaqtLZRVsb+f4qVgDHRBHx ufuZQtX+0djQ1tNsio3mSfmdIdo2XvZtNK95ZpkVesA0zXURt5Nre7famcZzDcuLxeqK yxVQHbZp3mxrIJlTUKtN0r4ut1P7hl0xYspYYJYxH/1AUiG9XmjJJYrnGs/kpxL49f0p tUpg== 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 b11si131223oii.11.2020.03.10.15.35.08; Tue, 10 Mar 2020 15:35:20 -0700 (PDT) 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 S1727857AbgCJWeK (ORCPT + 99 others); Tue, 10 Mar 2020 18:34:10 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:43350 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726273AbgCJWeJ (ORCPT ); Tue, 10 Mar 2020 18:34:09 -0400 Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (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 EF38A14BBE02E; Tue, 10 Mar 2020 15:34:08 -0700 (PDT) Date: Tue, 10 Mar 2020 15:34:08 -0700 (PDT) Message-Id: <20200310.153408.209273615201195266.davem@davemloft.net> To: shakeelb@google.com Cc: edumazet@google.com, guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, gthelen@google.com, akpm@linux-foundation.org, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] net: memcg: late association of sock to memcg From: David Miller In-Reply-To: <20200310051606.33121-2-shakeelb@google.com> References: <20200310051606.33121-1-shakeelb@google.com> <20200310051606.33121-2-shakeelb@google.com> X-Mailer: Mew version 6.8 on Emacs 26.1 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]); Tue, 10 Mar 2020 15:34:09 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shakeel Butt Date: Mon, 9 Mar 2020 22:16:06 -0700 > If a TCP socket is allocated in IRQ context or cloned from unassociated > (i.e. not associated to a memcg) in IRQ context then it will remain > unassociated for its whole life. Almost half of the TCPs created on the > system are created in IRQ context, so, memory used by such sockets will > not be accounted by the memcg. > > This issue is more widespread in cgroup v1 where network memory > accounting is opt-in but it can happen in cgroup v2 if the source socket > for the cloning was created in root memcg. > > To fix the issue, just do the association of the sockets at the accept() > time in the process context and then force charge the memory buffer > already used and reserved by the socket. > > Signed-off-by: Shakeel Butt Applied and queued up for -stable.