Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1674818ioo; Sun, 22 May 2022 23:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEJQspV6Vb63YnF1SFo7a/5AbnF8/d00VzemHenR5E79mDev8S+XG03C8mtGo0eqp6bxQz X-Received: by 2002:a17:90b:1808:b0:1e0:4dbc:8781 with SMTP id lw8-20020a17090b180800b001e04dbc8781mr3953869pjb.58.1653289091147; Sun, 22 May 2022 23:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653289091; cv=none; d=google.com; s=arc-20160816; b=neAiTJClLNZtyOuetyZ2DsgTyQdqCMkcK+V8tKXMxkp/WxVVQLN5oKto5hSXLH5RST pO4jYBNShg14BOz08akOnQcKLHWudB3DhACc+QuAMAsvXV/FAoFlZHBuzWq72w+EzPj/ xolMjIxPbl7rVlJZdWDkK1qOmq3x3SUWDD4ZOGn5+TJdWrNziCV/Et6uHpSGitJuHFuL QOwolOLxERbDhr1UHkHPDTXQe2Zn73P1kdl83kFtfR1qg2VAZGwA6Uqm0PdavjehNv/z OUTpzrBhQrTbehViJ6nEh5gLLlvSbKXCQqyDvcuJvGP1bub4E1L9+H7ZaTwKvZLKNYOl hQJg== 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=Wb/V91Pwh4wB3EAs6xgX+enNMi2t+13tZlysFcCX1i4=; b=pBXSB53f/hsqJ6qtcgJ2SXbVhd/p09VUyyHhU08Dru1Dd6q8m646Hn/42llq9y3OAL YyPjr86JAic/jzK7d45CGuU1RFukQT4ZalyGKPizJP3CwVntUINX1aoQUzX5UJe73aS3 b7rVobEzqj5tTrzNC+108lCoEjgtARLRBW2bfMPvDwi/7Iz8m2ylHng3SWxZPa5Vd8id ehcNMUA3wEzJHnVfJzmM/9XJlK17Vrm0GnfA0IzSdTGS1YNtjkE15GiBf2uVNCGWS+PA pHlUadJpSCsyj6AYKqsSoeduWmwrnlczL9Deb4jFIlXzT4k8fCyloubuQhNG1njq1LEd j7Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=EhsaiP3e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j62-20020a638041000000b003fa010a9f7csi7885342pgd.125.2022.05.22.23.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=EhsaiP3e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 3E00E2124E; Sun, 22 May 2022 23:23:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245286AbiEUQi2 (ORCPT + 99 others); Sat, 21 May 2022 12:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344944AbiEUQiY (ORCPT ); Sat, 21 May 2022 12:38:24 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F34C62A20 for ; Sat, 21 May 2022 09:38:23 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id l13so12326241lfp.11 for ; Sat, 21 May 2022 09:38:22 -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=Wb/V91Pwh4wB3EAs6xgX+enNMi2t+13tZlysFcCX1i4=; b=EhsaiP3edvHWkF6iZ/g4kbDdoucu2Hg9/DwUaWCO1Iu39vG/HSh7DpGYTKIBa8nltX 7fjwk8jAcmjbcbZJLhP95KzdEjzefrc50ViZXA78q+dlaTqNOQqO/F7nOOFKaFVThoOP dU7Wj/9rE6xQZzw0Y2K39AqL7cUZtdLf1QAu1TaSF/Ooh8+2Q74tSwpYs/aw/RKVFDBv iDwRJwtQ0zedkl8HFdOeziMW5IH+3q55Nzg0+/Ec12EsHwr+57XmAqP66tl5ItbXKpDQ g1/J1VMpu7IVTmXkHN7siOvn389e2ft7AgNIpbEelIf2PqHCdv7vJ9n/x3Yk81guXbQR 9hog== 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=Wb/V91Pwh4wB3EAs6xgX+enNMi2t+13tZlysFcCX1i4=; b=bSUQY3v0hTDHC2yZ6w2OS8mvgFnBAyfx1XJODKXGxG/1MwarbQSoscPRIlXUFIfIEg /AJjPNbfx/FADAeGZiVcebuGMaal3JCQsrxM0PRuXkvBKQ0cWgX5fCLhE7s3BlWOZ7Bt 7dXmfXOC7hu8cSjPTSx+XUzV00RJ+j4RtRzmebeoCuZVYGoPR8TEH4+/mQF0//CSxq2M F+rpA8EVJWePFRGwbCV5eiGAb+ByVN8Jl8aZbKHMjPaqP/nLBl12HjYAYw/S4pXoZtph k1EG1Z0RxAzHsD8JFBPVDMoc8i9gZhXA/K90xoWOi2viHokOUsIU7Ih1qFLD2QC5JXg1 VdvA== X-Gm-Message-State: AOAM533A74Ln3m1h2+e93ckNdlhvV4Y4DM69qzV+Rpa/zaJAwHGzRv9N FmVdvnl08EY9ZU/AbfRc+6L+dA== X-Received: by 2002:a19:7104:0:b0:474:d376:2cd3 with SMTP id m4-20020a197104000000b00474d3762cd3mr10438574lfc.175.1653151102636; Sat, 21 May 2022 09:38:22 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.185]) by smtp.gmail.com with ESMTPSA id bf16-20020a056512259000b00477cb9b8762sm960850lfb.50.2022.05.21.09.38.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 May 2022 09:38:22 -0700 (PDT) Message-ID: <16f17021-61a3-c6f4-f60c-1acd3a0b66b9@openvz.org> Date: Sat, 21 May 2022 19:38:21 +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 5/9] memcg: enable accounting for percpu allocation of struct psi_group_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 pci_group_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/sched/psi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index a4fa3aadfcba..f0b25380cb12 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -957,7 +957,8 @@ int psi_cgroup_alloc(struct cgroup *cgroup) if (static_branch_likely(&psi_disabled)) return 0; - cgroup->psi.pcpu = alloc_percpu(struct psi_group_cpu); + cgroup->psi.pcpu = alloc_percpu_gfp(struct psi_group_cpu, + GFP_KERNEL_ACCOUNT); if (!cgroup->psi.pcpu) return -ENOMEM; group_init(&cgroup->psi); -- 2.36.1