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=-5.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 9E911C10F27 for ; Tue, 10 Mar 2020 15:54:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F2F320578 for ; Tue, 10 Mar 2020 15:54:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fnr9nH/1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F2F320578 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F20536B0005; Tue, 10 Mar 2020 11:54:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF8356B0006; Tue, 10 Mar 2020 11:54:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0E256B0007; Tue, 10 Mar 2020 11:54:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id BA01A6B0005 for ; Tue, 10 Mar 2020 11:54:01 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7A58A8248047 for ; Tue, 10 Mar 2020 15:54:01 +0000 (UTC) X-FDA: 76579898682.30.class47_5d4db31ccc24a X-HE-Tag: class47_5d4db31ccc24a X-Filterd-Recvd-Size: 4436 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Mar 2020 15:54:01 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id b1so6476078pgm.8 for ; Tue, 10 Mar 2020 08:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hyrZhGrQSEDWXCf6l1K0WVVemgS8j81vIr9KuEMeNkw=; b=Fnr9nH/1FiSHsgd5I4mASsBjBOAmLtnO9KW8gGJGjtqZ0Ies0iCUFa54FNxkQwMVH8 9vozAHc88+mmTFfl0t8MJbh6NYELuNIstZCIwR9xp2lvT0U4DIVD5U27Y45Zt/3JjwLp i/18FPdI/yaUtIiZixGoY4EEBOXox38OvshHlJjNP4TwhQ9IIG0YaTz1gix2tUH36g1P xWot2m6eSJJfsRB6nnLF9GibDnWJba71embpqUTI+7dT02Sn8uD3GrKVmiJPgqcVFssa veqYq0kbeFu/nR8R5BxDg/vflmaADT6Bu4YfAKLhdKQ2e4nuvhxraukxO+555BkJCzpB MpIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hyrZhGrQSEDWXCf6l1K0WVVemgS8j81vIr9KuEMeNkw=; b=j4ZzfmTTGuPzqU3Eeg1KdaqhVGFQ0xLjWUe7FQYUPLE3PCW/fxJ0iUCLnHKuDzDOce CFTAbCGoYvpzHyX3pSgPdVhqU+UwrhHxsVtt7WB2VtzGZggU+RFL8CCeviTYbwIk1wYq TVzOUsOP1sKcfEYAV/lL5Mi8vGFYxztttElyHMUurUIuFZKdzCUorZm27yP2bWaYKyK5 2UANyxLrPyoKjixo3NZkf2FZJXiTGELzdE5PetCz10JbeZepw3hDP2lAAy7ZmNMtUA3H aoHHN1QODvKdCPNhS40iBcVCOWNu3VBh41OZeytPS50T11IVk/RIFPkaAN0KV1EfbG1k fOtg== X-Gm-Message-State: ANhLgQ2Hb/7xvrTnyzAEILtdv38F4xyICONRLxO52sgzNjOyIX5UXAZ6 xBGA92gX8OojWSayQrQEz6U= X-Google-Smtp-Source: ADFU+vsR8/enDWMRGI9zYCByh8vYrAJV/k0ZVXaSFoQmagS/wnBOwBl7rNs8nV0VXWjtxaN1jPTAdQ== X-Received: by 2002:a63:7783:: with SMTP id s125mr21230881pgc.214.1583855639885; Tue, 10 Mar 2020 08:53:59 -0700 (PDT) Received: from [192.168.86.235] (c-73-241-150-58.hsd1.ca.comcast.net. [73.241.150.58]) by smtp.gmail.com with ESMTPSA id z17sm36944540pfk.110.2020.03.10.08.53.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Mar 2020 08:53:58 -0700 (PDT) Subject: Re: [PATCH v4 2/2] net: memcg: late association of sock to memcg To: Shakeel Butt , Eric Dumazet , Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Greg Thelen , Andrew Morton , "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200310051606.33121-1-shakeelb@google.com> <20200310051606.33121-2-shakeelb@google.com> From: Eric Dumazet Message-ID: <652106b3-975d-b8bc-ca27-682c0c8d8aa3@gmail.com> Date: Tue, 10 Mar 2020 08:53:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200310051606.33121-2-shakeelb@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 3/9/20 10:16 PM, Shakeel Butt wrote: > 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 Reviewed-by: Eric Dumazet Thanks !