From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20226C43334 for ; Mon, 13 Jun 2022 05:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233586AbiFMFga (ORCPT ); Mon, 13 Jun 2022 01:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbiFMFf4 (ORCPT ); Mon, 13 Jun 2022 01:35:56 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36F811151 for ; Sun, 12 Jun 2022 22:35:19 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id a29so7142137lfk.2 for ; Sun, 12 Jun 2022 22:35:19 -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=B3zm8wtF1vA2GYm2+mdF7egB2sMmmpE2kcaPBaO2eto=; b=aNTN9ecStVPQ2d3BHO8r2ERVbHTttzP8TpBGu400gwgeTcHpH5cOc8cGKcJF5B4VSG Pl404daaNaSR+XfYhnMPIJuJDZNnXll9sSKc8Bl7DpIBinOElRj9Cdogfo8nhbIPgz6H LEhnRv6PLI/1q4OQhQVbZHRXsvpYNjKANwS6bgzq+oxPSUzB7Oijv5PyZP6r2dUx8G0b 5/U0JAHLUzb4KnI6Ev9AKyFvBj77iQEV+KqIkwQ1NbPYXEy0SxOYw8Yaln47mLwPQ3Ko TdBRQtjCGU4GK/9EIclgy8Gop96FJszFi5oVXiUUTrnqwe52akMXbhog8arLPS0+Gyux fXRQ== 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=B3zm8wtF1vA2GYm2+mdF7egB2sMmmpE2kcaPBaO2eto=; b=4lWfaxcQMmE/r5zgNxarulPq2jwnRqqMH9zXUXglNM9T4zMxsPCZKksUjHlejEGdJg MeIBgxYiJxYA6hlseadcxjCAKdGxadr1BqfYCCjm3RfAX+JOw4D/6ix67x82aEIENFfl ni0lKt4cvMnXDE+4vYue2DXkz0Ck2Fx6RmUS8nbnp0Ch1baq1QiUEHTkTJFVIqfOJACB MkFoW4AC6quxwl4rqxyvB0XSFZKyOwpnOQWi0QpbZbPx2uXKf2J+BlFuvQzPzW0JEJvD vnmzBxmfgXdyikjk9YEbZ0QfWnklB/AYn9ntTaNWVR+G6kyr6yjrdId3p1OEAg6cL20g WP0A== X-Gm-Message-State: AOAM531K4O+UcB72gvzcHKyxjPdKIsn43UvbYpQYQyIbcrbKYNrNs91E YIB6zwk2gXQ9bJl3fnKai/Nqlg== X-Google-Smtp-Source: ABdhPJyFjrBYaSumRmMWd09J6whp9J9igWSZ+y3nTisSme3IrGUsLbSkT5Qvc8TfA25hMj3+GYM3JQ== X-Received: by 2002:a05:6512:1595:b0:479:1e0a:283b with SMTP id bp21-20020a056512159500b004791e0a283bmr28839782lfb.141.1655098518177; Sun, 12 Jun 2022 22:35:18 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id s7-20020a2eb8c7000000b002556a17e193sm875735ljp.38.2022.06.12.22.35.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jun 2022 22:35:17 -0700 (PDT) Message-ID: <33151594-4168-d01b-56b6-dc996d226a7d@openvz.org> Date: Mon, 13 Jun 2022 08:35:17 +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 v4 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 , Muchun Song , cgroups@vger.kernel.org References: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Content-Language: en-US In-Reply-To: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Acked-by: Shakeel Butt Reviewed-by: Muchun Song Acked-by: Roman Gushchin --- kernel/sched/psi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index ec66b40bdd40..c95e87269fc5 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -957,11 +957,12 @@ int psi_cgroup_alloc(struct cgroup *cgroup) if (static_branch_likely(&psi_disabled)) return 0; - cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL); + cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL_ACCOUNT); if (!cgroup->psi) return -ENOMEM; - 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) { kfree(cgroup->psi); return -ENOMEM; -- 2.36.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vasily Averin Subject: [PATCH mm v4 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Date: Mon, 13 Jun 2022 08:35:17 +0300 Message-ID: <33151594-4168-d01b-56b6-dc996d226a7d@openvz.org> References: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: 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=B3zm8wtF1vA2GYm2+mdF7egB2sMmmpE2kcaPBaO2eto=; b=aNTN9ecStVPQ2d3BHO8r2ERVbHTttzP8TpBGu400gwgeTcHpH5cOc8cGKcJF5B4VSG Pl404daaNaSR+XfYhnMPIJuJDZNnXll9sSKc8Bl7DpIBinOElRj9Cdogfo8nhbIPgz6H LEhnRv6PLI/1q4OQhQVbZHRXsvpYNjKANwS6bgzq+oxPSUzB7Oijv5PyZP6r2dUx8G0b 5/U0JAHLUzb4KnI6Ev9AKyFvBj77iQEV+KqIkwQ1NbPYXEy0SxOYw8Yaln47mLwPQ3Ko TdBRQtjCGU4GK/9EIclgy8Gop96FJszFi5oVXiUUTrnqwe52akMXbhog8arLPS0+Gyux fXRQ== Content-Language: en-US In-Reply-To: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" To: Andrew Morton Cc: kernel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Shakeel Butt , Roman Gushchin , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Vlastimil Babka , Michal Hocko , Muchun Song , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 Acked-by: Shakeel Butt Reviewed-by: Muchun Song Acked-by: Roman Gushchin --- kernel/sched/psi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index ec66b40bdd40..c95e87269fc5 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -957,11 +957,12 @@ int psi_cgroup_alloc(struct cgroup *cgroup) if (static_branch_likely(&psi_disabled)) return 0; - cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL); + cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL_ACCOUNT); if (!cgroup->psi) return -ENOMEM; - 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) { kfree(cgroup->psi); return -ENOMEM; -- 2.36.1