Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1674893ioo; Sun, 22 May 2022 23:58:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFzr63i8PirDPhsOygVOOSh0mKDK7DJxXIno6oyTa2p/DZm5RJ1n66fIptBXtwAa8wWpHN X-Received: by 2002:a17:90b:4a8e:b0:1e0:3839:2bcf with SMTP id lp14-20020a17090b4a8e00b001e038392bcfmr7179996pjb.58.1653289099792; Sun, 22 May 2022 23:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653289099; cv=none; d=google.com; s=arc-20160816; b=bQLL469kqhsfbemcl8lZVGfA1Xl+ksKaWbbw4g5fc9iELJPzPYRh7fSpGaVzlNR84l pbC9qj4b1IppNTitTohmTkCDLvlJPzHdj4hIgQDmeIHe7zjRGZ5dTBc8FpjzY60lcu0t wP6EBuAF7IQa9+xlTbskRfgZaE9JWneG5/07QdfXR2Ds/kC/S4KMG9l5zn+FRDYHxcHR uPo/jxbKf6l0ugORWBqO0U83y2QsTllqcymBS9wyNcpDL18BFDt83+qsh/YfSb0Zw4r3 5qMcoL6Luk2F28IWSBJqKSgPCFN1zOk3B+iwL9jVhSPph7O9S+tXFcOb8N36TGMIMCja iujw== 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=ubEdKOLxNSsh97bDo7kpC8y1FqAK+i/uT0ov6eXAI2o=; b=JIf9KgpS+//RToPXHTJMx5i8CJamEpwjW4mLOoL9snIVyvq9Gbd3flad1F0zoV9qs5 zy00Y/SdsbOtuxYhkX/bwkZOKGrWR+iqLmvzzAA2NnwW1lzXkG3sY/Reth5m29tEiQBd 6OSpj0KSUDk+Qq8OdroukTquipT8MRlPPEvxb5NW1n/wvoGBYvk8cHWWquR32u4Mxh1+ I/1jhvZ357wOeayQVhsWcwvvM3KZ5tsPFgIkOjKHaWBh1HYupazDbZhD4rc7oIoSygh7 qfuoIHN/sh+MSjTSzIARdVAIyPSxv/aMooZPmZ4MxbBGyxcocCbiY+bM0+h28mWquYhl kB/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=VGOpXYto; 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=openvz.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q22-20020a056a00089600b0050db6efbaedsi13261072pfj.105.2022.05.22.23.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:58:19 -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=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=VGOpXYto; 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=openvz.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1A8A5A598; Sun, 22 May 2022 23:23:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233284AbiEUQik (ORCPT + 99 others); Sat, 21 May 2022 12:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231387AbiEUQii (ORCPT ); Sat, 21 May 2022 12:38:38 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0203262BDF for ; Sat, 21 May 2022 09:38:34 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id g16so12661462lja.3 for ; Sat, 21 May 2022 09:38:34 -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=ubEdKOLxNSsh97bDo7kpC8y1FqAK+i/uT0ov6eXAI2o=; b=VGOpXYtocMKIeshgklWD1Zo9cIZadjw/jBv0T7SITGnfSw+kY7kyswsQG+yKDOPdIL lgbOfYW4tytV2kcy9vuPjd1SIFXGAdT0RBbbSvFh+vlWmikbE0fhup438dTlu81UrMd1 2ZjPKcME4smlcKI0In8IqM6w/ffUsdXEjJ3xK1yYr0BPOerlii2ms/hIZixBjf8jwAue EFgO8Mj9dhK4TkCHLycE1wR2gkSB23Tgxtl612CMU+p9bfxBlIpcRplIQ7eMihOoZbvx Iple/oQOgga471BAYxfPyoTU+4ZAAVOP71yOR9Cudi0h3whHn+xwG1XL52goc/glgHsH fSQg== 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=ubEdKOLxNSsh97bDo7kpC8y1FqAK+i/uT0ov6eXAI2o=; b=d0aWed/OIexIKB0gxDbZ9+SrQztIh+rTJVtapirXtyZwg1PUw63XtXjGoiTC23N2q+ A0+UXK4P5ekkiK67/pS5tI74v3WJ5fljV7HSJd351r7iPFMA/hTbwm3fh79Jn870G+p+ nSLK3iQEfJAu2EGbrMkRJQdWSLtCOr8WujN/Eg1vlFS0PzPUpUY0o4zvHoaVTdPGSU6S B+uq8F4v1XMaxgQ2mpNUrf26TYxFYNhiWNKu9sDWGZ/pF+qvEC10+9T14hMSCr8wY3Fu Id19XTi7hGJitZqnVsnuQA4uC+41mllUB0RQiZxDh/27UM+MfpNCyg/P9NITK4OQEP5J V/2w== X-Gm-Message-State: AOAM533G7AWMpRLw2uZDkYoR1WzkGI7cgfShwhIhpIrxYyPYF/OE0J97 0t8aJfoj+5syOoDs+VvWyN7RVw== X-Received: by 2002:a2e:b053:0:b0:253:dd50:b93f with SMTP id d19-20020a2eb053000000b00253dd50b93fmr4948944ljl.277.1653151113204; Sat, 21 May 2022 09:38:33 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.185]) by smtp.gmail.com with ESMTPSA id h7-20020ac250c7000000b0047255d21174sm1116566lfm.163.2022.05.21.09.38.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 May 2022 09:38:32 -0700 (PDT) Message-ID: Date: Sat, 21 May 2022 19:38:31 +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 v2 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 , cgroups@vger.kernel.org References: 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,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 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 --- 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..f76cb63ae2e0 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