Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1664616ioo; Sun, 22 May 2022 23:34:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS2cDDb5yzS1vmzlZoCgZThEUkaCISo0VAI05LaTgpDPb9GFClICIK+T560ue9khGP4uzr X-Received: by 2002:a17:90b:4d11:b0:1dc:ec4f:a19c with SMTP id mw17-20020a17090b4d1100b001dcec4fa19cmr25136318pjb.117.1653287672487; Sun, 22 May 2022 23:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653287672; cv=none; d=google.com; s=arc-20160816; b=cXPP0hWYKzvjXP3PJXJq1eqy3Fo3g9MT4PJ8zs6yirREEi4EI/mVVRS6fLXCckYT6n RgCukyFwS2q5dOSa7TrDFT2E6TnBAxVLfY4FiaMUw2Izun3/gzRgMUz/DBXjT9AozjtA J3ByjMbIxUkVsf472DcgkJVQAF0SN2zitFJe6E4ZDEQxJjoofIVEb1S9bSurSMRLoGlo 8qRjni4lUKGlYWzQH4yaoO56tzmGDOfnqkACzy2qBKK4Csd+Edqdtsd2MboKAbc8NAdR qQ6Rpub9kDprI9XTJZ1kTm1ebGFoklo7YD4rodWbr05loM65Hh5w2t1zBpkHGa10I+VE d8cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SS4jw3jE67JbDZTZdbjql/HYvYPNQbA1HjLNkPGV220=; b=wNGbWKvA1og3aE3r9+9md3yNu4kuUTHcCpkHARcgn4UcJsagxICl9x0MJYFrdElejx qpWCn5bCOQ81RU32U2T49usKwQpN2SAeJ8/UPI+5AP0TWDK4MdHbEha4/xriW0DfG7M5 cm+wmhO3hTZHlGRjrUfN6wLfUiuYeNTPF/demjQFG7l+gE5NoEd4qTRBldmDhCbD0OFJ /95C6DD0W2xOOF+FlRfi0s7JKQkXMup0NFrvzb5Pyv5R91g8YRH4YV0e+UMPtXNHDtSQ +BCUpTFbQT5ZSGUfTuw3fhmH96zWHR8LOfYoVUJ0UV+K6Rpho8yKr5A8yPdJRMOXQUbI UOWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=tH30EpVK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i70-20020a638749000000b003fa27bf448bsi5193024pge.71.2022.05.22.23.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:34:32 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=tH30EpVK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D66B94757C; Sun, 22 May 2022 23:09:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239125AbiEVGhX (ORCPT + 99 others); Sun, 22 May 2022 02:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbiEVGhU (ORCPT ); Sun, 22 May 2022 02:37:20 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4E1A41637 for ; Sat, 21 May 2022 23:37:19 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id ev18so11348128pjb.4 for ; Sat, 21 May 2022 23:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SS4jw3jE67JbDZTZdbjql/HYvYPNQbA1HjLNkPGV220=; b=tH30EpVK2h/cCwkIA89339RbASD9rwQYzV2mpWXdJeN1f2qCoMf0aw+zavoo/5g+Im szoe9euSzxHQzARGh9ChqS4tUPL1BtXXyt39qSSHWItE4nzGG4KjRDUi2GXIutzNildO wswdljmUZs04AM1qJeN5L4dR80f/jFVvYOfM+kYYqWqT1Gn6VtxFyeRCyxWMu8VVi9z4 rq9SjvSnZ7eSzbzO4IXPUb/T1UV/BGSnSzRpOKGBHaNJq5cqbp7YL4osznVW8jiRpg8k RS0QtL1EeAIbWz230hGs/rrOofuOszZl9MPmnt2Ei5ECuQJAasNZlslU1Q5OSQXKqKvf Pc3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SS4jw3jE67JbDZTZdbjql/HYvYPNQbA1HjLNkPGV220=; b=SlxNpga3PjT0BVPQE+rIhsSCh4/4qe2iwx+FCXAlnco3vdL3XY5vUN4mp0bmDHAxFw 5AWdx+mVJHGEdhoo7wOht/7SyBxYZLoJW2JRlY1lYjFByB2kX+Ao3MwMvhG24jd/rY1z rwdnZ9eXA8wXJUqB/7tHCv59UA9xBUjPovs7kGqrzy6P1DC+D1VbEYiBhi8YrQIodUwI c7w6n3fSyFBwUjmMvIQYy41U+Hp1X+Et2wdsx0V3GML2wHCNpZgC0fnleaqV4OLbXW+4 DdUwOt6tbyXc73cBnCAagCiTmh2hmosMBavXk40rZlKMLCeVl13k/gg8iziZ1G3hPCv5 W5iw== X-Gm-Message-State: AOAM532agw7EFJAeeryZA5CQoiNJt+gtlj/ESz8ZrJ0N6B5xFLv7Wt3S gMLlDfaGhwxowIQ2y8uUGpuLig== X-Received: by 2002:a17:903:481:b0:161:6392:c350 with SMTP id jj1-20020a170903048100b001616392c350mr17482105plb.17.1653201439206; Sat, 21 May 2022 23:37:19 -0700 (PDT) Received: from localhost ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id l4-20020a17090a660400b001df666ebddesm4677245pjj.6.2022.05.21.23.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 May 2022 23:37:18 -0700 (PDT) Date: Sun, 22 May 2022 14:37:14 +0800 From: Muchun Song To: Vasily Averin Cc: Andrew Morton , kernel@openvz.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Roman Gushchin , Michal =?iso-8859-1?Q?Koutn=FD?= , Vlastimil Babka , Michal Hocko , cgroups@vger.kernel.org Subject: Re: [PATCH mm v2 1/9] memcg: enable accounting for struct cgroup Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 21, 2022 at 07:37:36PM +0300, Vasily Averin wrote: > Creating each new cgroup allocates 4Kb for struct cgroup. This is the > largest memory allocation in this scenario and is epecially important > for small VMs with 1-2 CPUs. > > Common part of the cgroup creation: > Allocs Alloc $1*$2 Sum Allocation > number size > -------------------------------------------- > 16 ~ 352 5632 5632 KERNFS > 1 + 4096 4096 9728 (cgroup_mkdir+0xe4) > 1 584 584 10312 (radix_tree_node_alloc.constprop.0+0x89) > 1 192 192 10504 (__d_alloc+0x29) > 2 72 144 10648 (avc_alloc_node+0x27) > 2 64 128 10776 (percpu_ref_init+0x6a) > 1 64 64 10840 (memcg_list_lru_alloc+0x21a) > percpu: > 1 + 192 192 192 call_site=psi_cgroup_alloc+0x1e > 1 + 96 96 288 call_site=cgroup_rstat_init+0x5f > 2 12 24 312 call_site=percpu_ref_init+0x23 > 1 6 6 318 call_site=__percpu_counter_init+0x22 > > '+' -- to be accounted, > '~' -- partially accounted > > Accounting of this memory helps to avoid misuse inside memcg-limited > containers. > > Signed-off-by: Vasily Averin Reviewed-by: Muchun Song