Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3655833ioo; Mon, 30 May 2022 06:58:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPqbclbmXSG4HWnNrwaeNPiLXdXMLkO4S8Gk/SlnxJYSQpv67/2SKJ3ZSfUUTZUdYOfs7f X-Received: by 2002:a17:907:6d15:b0:6fd:d985:889b with SMTP id sa21-20020a1709076d1500b006fdd985889bmr50181147ejc.753.1653919117918; Mon, 30 May 2022 06:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653919117; cv=none; d=google.com; s=arc-20160816; b=LoNwqFESDltQ+FErXOjY9BvlWuum6HEXyoG2oF1cHAONCuqMQCJ15RgxZ9Lvfx3qDj edqtunD2QQQhs/k0sMeC8C9PIWr590liNsfDiaaf83TmH3mBXYsxpFOyvRMRjQUBnn+h xTduyGix2NNHCqvRiIZCeA0/7DnZpNGYVQQtVjWz1oNj9U607LtZU07Y2aM4Js6DOWiw AcmMVR2o49u38TMOUx2nxg4pBG11NQBYoE3Qen5OCQpUoeVwdx2XYYwQbxJ9Bm09U0hp m+CGIXan+Yi9dQg8TWwGw0+ThoMuIqFBNB4iFtTBSdNlMfy8YBHijqxQoDXdZGEs31ty CkqA== 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=lq150UndXxHEWEhIvsqNd7aCUGl0NaprSMERTMCukMc=; b=n4fJ7dxzC/IIr4dHhuBz2Pd95sJCIDEnGEFblleTeCqhQT2yaTMfVJOcWODO2+b1Xy 6yRMBheH9xn5CTKD9NvlcYm1CM7IVx+GYGxM+lh3Hbz8Tv9w3TIBg6pIl/ZZs9HjM4O9 0XkJd2iYth2cM/p27Wn2sgD/L77H7yQue6F/pWmK/etSpus5jLmgOsxdT1T7D27erJhT rUELexipO60Sl792dkUfpwUK0ZMcmH8Qis6X0uUBGRjJxSdZllgNDp+G7xumeOPSxr5z UpMnFPtCIyfZDY/7KYYhlIo8C7+0He6qNavIe7PGt0CdIJaMvrhtjtajneAeZAPnCdxg inew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=yL39YrAU; 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 a23-20020a1709065f9700b006f3b763040asi10516421eju.141.2022.05.30.06.58.09; Mon, 30 May 2022 06:58:37 -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=yL39YrAU; 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 S235726AbiE3L0t (ORCPT + 99 others); Mon, 30 May 2022 07:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235731AbiE3L0n (ORCPT ); Mon, 30 May 2022 07:26:43 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521A4AE72 for ; Mon, 30 May 2022 04:26:39 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id g12so11217494lja.3 for ; Mon, 30 May 2022 04:26:39 -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=lq150UndXxHEWEhIvsqNd7aCUGl0NaprSMERTMCukMc=; b=yL39YrAU3i/NoAsVN95rMmJdSBldmOz1PwlQ73jfMuWdBXrupcnQd2G2xM7mDHLOTw 5cG1/LbM9ELIeheHf4QRIj9qoEGrwWMMYtTwVRLQaMrZRY2GTI6OHsCLJntYiy66xJLY dcyIU7JJNYbu0N8ONgoWHtdXARu59CTqL/J5y5kDSzriAP6IQIHw/6y+net9f403FUOP Aes5Xixs/Zs3CgFNNxQ0wi8z2ztQjubVeeh91mEi5dPW+K70JTAiWKmInlePnVUr/5IK DTGNdcEdAZiKlmqMNwtccV54snA1/n0921UB4g/zMC0+ndU8bwXFam+o5cqi5VihlEFc srgA== 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=lq150UndXxHEWEhIvsqNd7aCUGl0NaprSMERTMCukMc=; b=rT/C28W3txH7oppLSNu7NnJqxedzcjuqUP3wFsXXz5CzygRIsqPdpaMBRiVNu+O9Om cnxED3F5VO1OVNqv+TMpenQsFkPwGkOoEMbGCaboVrOQrlSQDDBPCHJPzPlPF9/pefSA f/U021tJDHHaE94WJOKDPSd7nsFmCTc/uGLWMyPqMeDLejbOR/VG+PvCMgouCez/eJcB e1ZEjQuEKo6b+5hDpgbeIVAf11OhRyjahoeweFndah3d7tlMXfetolv51br57kn3RXKD buPgevN1BSBT1aENwzkY55/FvwJMtdyulRzYIH60lw696RzYUlIt3ajmK7cninGV6Dl/ IJwA== X-Gm-Message-State: AOAM531nthlnNZCliAZz2Ps60+RY3WyXlyc8lM4zQh66b04cyOIFWtXp 8eIQuZSLHF2EEEH18MoypB5KGw== X-Received: by 2002:a2e:a286:0:b0:253:bff6:ed52 with SMTP id k6-20020a2ea286000000b00253bff6ed52mr33837134lja.229.1653909998100; Mon, 30 May 2022 04:26:38 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id i16-20020a056512341000b0047855972515sm2257257lfr.72.2022.05.30.04.26.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 04:26:37 -0700 (PDT) Message-ID: <2fbede88-6ef7-4ce7-b3a3-ec349bc2cc06@openvz.org> Date: Mon, 30 May 2022 14:26:36 +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 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: <06505918-3b8a-0ad5-5951-89ecb510138e@openvz.org> Content-Language: en-US In-Reply-To: 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 --- 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