Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5954554iog; Thu, 23 Jun 2022 08:27:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vfu2+Y2mRflccyHHsMFlMY2aybaXHKuGGM54r5vP9kggwciNAO0Ad/KxhYf/ltvubJFo/c X-Received: by 2002:a63:a749:0:b0:40c:57e0:86c0 with SMTP id w9-20020a63a749000000b0040c57e086c0mr7870038pgo.265.1655998070961; Thu, 23 Jun 2022 08:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655998070; cv=none; d=google.com; s=arc-20160816; b=kxRAbGFfuGieZ0dgI2i1wkCIggGu2AOzCIQIM4zbNqD4+SaRzMUjI9NaBwIQof8UPI qQcPoOZfTrfqvufB/79sQtMIOIc5U7joYaJF/oMry1heciuFyc9BnbJHOsdDpHqx9+up Y0X/KYT/7tP/5mtGUR87Zk2wSbq8cxSLBA6GuDoFkZGNpYWAf9EuXF9y7hcyH2PPb4Zq VD9H1y1vBmQ7l8icze866Bb+7Sj/UoqWWWebRXaiKbvMjU9jQAN2EaO7HnpuvbNNIbj7 ByMN1aXawclBWVbWeTRlEQlZh2RxQXHORLarhv8w5nc1PLdb9J+9BXNg52E5sdfnE8cA EPiQ== 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=fYBLg0GorDblKEye4tioxlFuzZ/2NCtjLKl9KE3W8YI=; b=u+dPwBb6Hyp3P9h8kA0/EK6psEjVKlfVfRDq8KEYN2zULnNFjk++x1mkZW8CwCbpZm /pj0JDqZFnOlyfW7H9vNyrWtjQk+5pcAUefX7hCwDy9+E+CuoBAgLCxBF7hoG1dGmjIe 3NI3t104zs0s2/VJh8YomCWf/H3v7CDTxKdQavQgKwPTlDK1TEu60NfDZ2kguB4UBSHK qzUCMT1g17lSbZypxZaG62JEE7GMAbH5H2lF2pMGdvUhpeRMQ/9UPMTiwh6HKhFgCE6C wZjBy5rlNbdrFI5SaIh0WgcxjBl74dDLNQ2COQMT84fUdWhDmsLBs87baBEdnzwdUwje pMbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=ilILMVAc; 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 20-20020a621514000000b005252bb2fda9si11727422pfv.71.2022.06.23.08.27.39; Thu, 23 Jun 2022 08:27:50 -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=ilILMVAc; 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 S232069AbiFWOvt (ORCPT + 99 others); Thu, 23 Jun 2022 10:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbiFWOvn (ORCPT ); Thu, 23 Jun 2022 10:51:43 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EFB473B3 for ; Thu, 23 Jun 2022 07:51:38 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id s10so23575592ljh.12 for ; Thu, 23 Jun 2022 07:51:38 -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=fYBLg0GorDblKEye4tioxlFuzZ/2NCtjLKl9KE3W8YI=; b=ilILMVAcvthPkldn+Fa+LkoIG/WSsFH8M7YG6eZI6EykQ+3oB7c4PdbWYXjZqjJ+43 FWPcHN93ez+UtYY/3FGn60gVrWz2wmHIsFXq/TFUle1S2965DVGnZ+G7T88vtlrYFmp+ yXP01mugIN86XV+s+rNzVqBycfic42Rq5VXNV9DBPQH+yuwZrrP0STBifVHqjRAjGW7J uYweDn2FveDwN4KUNlAFLo/+FqPrpfOFrs2q/44dDgBdmYC7a4GXjqZwPQuqOjaHf6cx cJOheLE1U00l7XXoRAwkq1Qbu9NV/7vftEsfDxwdNHKeI9Z/sKkWD5mRMqV1KP3cgxL5 p0uQ== 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=fYBLg0GorDblKEye4tioxlFuzZ/2NCtjLKl9KE3W8YI=; b=l9ENv4Baen5jOF06CNeSK49bwX81KWspE3qJVYZJYzFpf35MNiNuUYNlFJC9OVq+NN WyIVpcuABJFYicrl269AB4z0IJgE21c8iexA6QHNnHTb8M8s0WfonmQDD9ffYTRmKhJn 3wlpOmnrxRHR1H18/YXMn/JC9DbHPwHi7/mRyP4JKY3YG8vgp7xIDVOuKqnuF/GYGQEw ifoCU+FIBOxTodI4d3I9/IEooAVPo4Paf/Up6a9t9U1+pwBkgldukLfNlCtNj5Punu55 liB6Z9Cad0C1rTCqyuYWnpBPx/tJh0fWPxrUJTZSpK4P9piDJqh+lEBEwf1Hc4RNEuHI bmQA== X-Gm-Message-State: AJIora/rdj+dJk0tx189WWWNlXoAxxAjNUN3YUG+qLk7SPL6TFKO/z7v 97Thi2z6ncaEO11BUYZnoZ+T/Q== X-Received: by 2002:a2e:2418:0:b0:25a:662e:5051 with SMTP id k24-20020a2e2418000000b0025a662e5051mr5149208ljk.137.1655995898416; Thu, 23 Jun 2022 07:51:38 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id q5-20020a19f205000000b0047255d210easm3025736lfh.25.2022.06.23.07.51.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 07:51:38 -0700 (PDT) Message-ID: <9c7957f8-ba89-4c9a-bd61-d86bca18a546@openvz.org> Date: Thu, 23 Jun 2022 17:51:37 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 From: Vasily Averin Subject: [PATCH mm v5 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu 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: <4e685057-b07d-745d-fdaa-1a6a5a681060@openvz.org> Content-Language: en-US In-Reply-To: <4e685057-b07d-745d-fdaa-1a6a5a681060@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 struct cgroup_rstat_cpu is percpu allocated for each new cgroup and can consume a significant portion of all allocated memory on nodes with a large number of 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 Signed-off-by: Vasily Averin Acked-by: Shakeel Butt Acked-by: Roman Gushchin Acked-by: Muchun Song --- kernel/cgroup/rstat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 24b5c2ab5598..2904b185b01b 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -257,7 +257,8 @@ int cgroup_rstat_init(struct cgroup *cgrp) /* the root cgrp has rstat_cpu preallocated */ if (!cgrp->rstat_cpu) { - cgrp->rstat_cpu = alloc_percpu(struct cgroup_rstat_cpu); + cgrp->rstat_cpu = alloc_percpu_gfp(struct cgroup_rstat_cpu, + GFP_KERNEL_ACCOUNT); if (!cgrp->rstat_cpu) return -ENOMEM; } -- 2.36.1