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=unavailable 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 67009C18E5A for ; Tue, 10 Mar 2020 15:54:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E6CF20578 for ; Tue, 10 Mar 2020 15:54:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fnr9nH/1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726702AbgCJPyC (ORCPT ); Tue, 10 Mar 2020 11:54:02 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32864 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbgCJPyB (ORCPT ); Tue, 10 Mar 2020 11:54:01 -0400 Received: by mail-pf1-f196.google.com with SMTP id n7so6679576pfn.0; Tue, 10 Mar 2020 08:54:01 -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=VW055u7mpMrVnyvy3pcO/XLWYg4W6n1SVa52KnW5CzToW2siIvtNuGf7fjgEq3vC7k U70YWN5nHimDkzLPTxZ1Wo7mS1MkKcbVtpaJsEmMbvl+ymyLfwKf0W7BEKUBpwfUnVV1 f3xq58TBFbq9XrtGdGIJJcdNezk/VZkOM0jwPffC9Elc8jnmtVOg5JmW//KGHEKmx0gc yJBf/gH0KrGztuE6mNfn/fZ/9qIKWWikruOH6Whj7HPL7aOJf++w4ep9tEWrXRqrTLy1 8DUEvk5b+3wLYNmdL2oH+GtsJ2NQVTguyXVknbeH/fWRANlvy6wswzSx/DzIWChdtkJ7 0+xQ== X-Gm-Message-State: ANhLgQ2DsXUD/1WtDHvLC0yZBxGWu5ZJEkmYyEU3CdSYWZPEJyAM3XBx bxsF2SwlwOy7WpPzTByfE19ued3b 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 !