Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3670854ioo; Mon, 30 May 2022 07:13:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqDG5OFefiFiyWTGaHtPQUVoF0tolrgD3Ssewy8aw8PW2yVhspOS1x7zYy0oOQjNUl79Bq X-Received: by 2002:a05:6402:4394:b0:42a:e84c:2cfb with SMTP id o20-20020a056402439400b0042ae84c2cfbmr59825127edc.97.1653920033067; Mon, 30 May 2022 07:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653920033; cv=none; d=google.com; s=arc-20160816; b=jpQaO+NiHPsDTch62WXhoV01NGbIrTozlHfmsiq0fKGtwTyYyFLI0Bhj3zM0gnFIuN L8qMtHOFxtQiS0XbMhcFtW7OZbWcg/obbJaCvLRusW+8PAKJJtmYjR7fAT7InfXTCZgc 4vklz13nB21Za+xL3Cl+Yg6EEO2l1juvLtTav/Mr/SgQRk9jOCL7QP1vlcwZEL28UGYu TSv7c/l+hqxqSQ6tv0Q04TRtsmNaXmPpLxHmXCsDxrKB53OBPiSsJ/74ZztSlmdUHvTf i1Jm+bwKoSf0/JEORtdiXipNQ/h+mmqsFHH1FkDmrMaJftHeLJSAGqn6Wx7TEadPvb0B guFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=gJ3rDFLPy4ULApkBUxHTk0EGt0vcK2KI8AydJnC3/9g=; b=NB/sOtyDf6exCjIm0gIJAwsbnbI5W6564/2J2raav2nQ/SbORiWLvEM4mim6e+vU2z nNMp4hue6MUzgre2U+UXgVa8dEg5ifHYAeUsDzUxTu4nv1H7Uds8OLIFzht84/IRRq6W 00m3R0UJiEiqSI1iC4aQSNuPQV9TF5XIvsQdIQZdW1Jyr3zU9UQSDHEzxJyYuP0dy/sv o70wJjZcs06hyZd3HfFpLDEMUXsosGtXDQgBBt7FH6WJKd6c5fvEa1Gx16J1Pd3/LAnE PNHl1aMsGEHNFXdKRO4J8wSlN8HxyBOSxY20QAP4CE4gotAhX7wuHOp9i3EMkGy1SNZ5 QCcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=qqG593hJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp12-20020a1709071b0c00b006f4a3a09585si11232338ejc.782.2022.05.30.07.13.25; Mon, 30 May 2022 07:13:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=qqG593hJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234294AbiE3L0C (ORCPT + 99 others); Mon, 30 May 2022 07:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235665AbiE3LZ4 (ORCPT ); Mon, 30 May 2022 07:25:56 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A637CDCD for ; Mon, 30 May 2022 04:25:55 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 5so2669762lju.10 for ; Mon, 30 May 2022 04:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=gJ3rDFLPy4ULApkBUxHTk0EGt0vcK2KI8AydJnC3/9g=; b=qqG593hJBCUB/gBVGHwV+mSoLplrSbhyFYq3PDBSf9ltBe5cbhiDVTixDWLmpRgpSF iwnEYJ3CldnWOW++RbsHRj1dDdnf1ACIBj4U5pFXbGUTGG3PIfMCkkFZ4O9pmyMTQZdr +bkD/2gvyOgyI32Tq9RvL0Gk7HXu5G8aGokuVFTqDri1kgWoFxAnzbvNkMZGwJ7X0pC/ Vo4Yib/yG+2PfVpjYrCniWHVoDRH8VE4U4ratzu+Ki+d0mlBS/uoNAO/pkdhAlbDd9zT 0FEfj/BPuCe07LV8OQdVYc8sBe4VAlfFQn8tOtL08gUYChTRAO+LzL4aGvw7Uv/RDEi4 vNVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=gJ3rDFLPy4ULApkBUxHTk0EGt0vcK2KI8AydJnC3/9g=; b=QtHZYbLujr43frt2NgT9jJTLDDqottK27N17iJ9ZYEzI0sUQTgam6st96ONzKkDGjX dO1zsOCRdzsgijwrRD7qA1fyf0WCnyiq3UykWtmryehRTpf5CkSdFTD/f8VzEayl/Hem fEBhHi0HlUt1pga+iyI92nwmIP3MvE2b1nytHnWt+P7nQ+/PICByApKdDRdPgOQfIYjm 24iJHemi+f5/SFPss4GxKNqoOBYqcpT453m1bjHpwFr0SxATRhxdyuDnunVpEWagd+/K zT+6MSbN3BY3jtTQD6fxNUFYdAKwUEPdAyLlVblwulUQfedib31ZZT2KTa3DkUtzS3rl RY7Q== X-Gm-Message-State: AOAM533+YVMlJdPkzKvw/bumdZRETPaWpfci6VHPPfUn4sTGzw9rCrGx g1UeoIFnk6pj/+I7YvGjwt9GTw== X-Received: by 2002:a2e:81cf:0:b0:253:bbe0:c047 with SMTP id s15-20020a2e81cf000000b00253bbe0c047mr33677010ljg.311.1653909953751; Mon, 30 May 2022 04:25:53 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id bq3-20020a056512150300b004787c77fcebsm2246335lfb.289.2022.05.30.04.25.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 04:25:53 -0700 (PDT) Message-ID: <8d20322e-928b-e995-bd5d-0695841c526f@openvz.org> Date: Mon, 30 May 2022 14:25:52 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Vasily Averin Subject: [PATCH mm v3 1/9] memcg: enable accounting for struct cgroup To: Andrew Morton Cc: kernel@openvz.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Roman Gushchin , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Vlastimil Babka , Michal Hocko , Muchun Song , cgroups@vger.kernel.org References: <06505918-3b8a-0ad5-5951-89ecb510138e@openvz.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 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: Roman Gushchin Reviewed-by: Michal Koutný Acked-by: Shakeel Butt Reviewed-by: Muchun Song --- kernel/cgroup/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 1779ccddb734..1be0f81fe8e1 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5353,7 +5353,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name, /* allocate the cgroup and its ID, 0 is reserved for the root */ cgrp = kzalloc(struct_size(cgrp, ancestor_ids, (level + 1)), - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (!cgrp) return ERR_PTR(-ENOMEM); -- 2.36.1