From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4B64C18E5A for ; Tue, 10 Mar 2020 22:34:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 90227222C3 for ; Tue, 10 Mar 2020 22:34:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90227222C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=davemloft.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2FAB46B0006; Tue, 10 Mar 2020 18:34:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 284096B0007; Tue, 10 Mar 2020 18:34:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A546B0008; Tue, 10 Mar 2020 18:34:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id F41C56B0006 for ; Tue, 10 Mar 2020 18:34:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CA6148248047 for ; Tue, 10 Mar 2020 22:34:10 +0000 (UTC) X-FDA: 76580907060.15.wine71_5ea7c4da4a060 X-HE-Tag: wine71_5ea7c4da4a060 X-Filterd-Recvd-Size: 2395 Received: from shards.monkeyblade.net (shards.monkeyblade.net [23.128.96.9]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Mar 2020 22:34:10 +0000 (UTC) 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.