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 2755CC433EF for ; Mon, 13 Jun 2022 05:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232709AbiFMFge (ORCPT ); Mon, 13 Jun 2022 01:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233588AbiFMFf5 (ORCPT ); Mon, 13 Jun 2022 01:35:57 -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 BFA3E11479 for ; Sun, 12 Jun 2022 22:35:28 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id c4so7088517lfj.12 for ; Sun, 12 Jun 2022 22:35:28 -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=zIUP7XJmmGybhomix4qhj4dsvVJz3qpTtmJxAHZo+FS3qMKA29sQ0rVxITb06XZqrD nZC+ARODXgb3uW8IID/NoPvHZF9I+vmsgg6S2S3doreOAfToddHYk1Xvd8rWktSA8nfW ahOnjls08LK/iVwueICAsn0ZIC7TfutQY9y1bJsENsR5gcnyHgUNUiHtMrbOcicbvOE2 QVKi01RzoRWCS8SpdjYkxAJRvKM/V18mk3VtVZeCBa7GBMjYuZ9WMAr51wHQPnrptMvn 8xgK0UlON2cwUtsy7uUQEVj443cXKJL8OSjA3MdZI+qOZ/kfjJeo689lqFDEg/SHaxHZ d7mA== 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=PnwwsaPHTVe4TvOuKQKYrfyPT5bpp475FCglbfSULdPg0fRRImA/fc3ERSWpi9uRNj RNnZ1HUFHL900ObGaj/AQzeUHE07i02xRpBycuIR3xuHuaFTNA6/DlN1jGaYlSXXmmep 6lJ8gqnpUHCdbt3KI5FejyzWbJzWaYmdW9KcfSHzNxb0/Pif3BSPN71Hg49IExIwT44D Y0iFO0954WjN4OSEfrfD25Yw68DcUGvKcJgy1YsPAYGsNDp+VPwEPSsg/QFQFwUdkifd 96Zo0+XZwyt3E4NemJJFzGGvty1Rf20EGxBlVbjIgPekhOKdohj/UxdHMO7o2VKafnB5 t/nA== X-Gm-Message-State: AOAM530erNCd+x7M0cJBWcWEDKw9hWGcBzWg3jclTc5AOtqIlJuxbpba H5VuWI36vWXeKN5GeNpSKE67smFrN5R7zw== X-Google-Smtp-Source: ABdhPJzvN/XuMilatlDTG99FEYXRhOvXWQuq2fWz3UrzAYP/w/zAkDHEQehBYIW4xnHBlzBchtcVjQ== X-Received: by 2002:a05:6512:2614:b0:47d:c632:896b with SMTP id bt20-20020a056512261400b0047dc632896bmr5177459lfb.532.1655098527149; Sun, 12 Jun 2022 22:35:27 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id j21-20020a05651231d500b00478f3bb79d6sm845297lfe.194.2022.06.12.22.35.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jun 2022 22:35:26 -0700 (PDT) Message-ID: <05bcd9df-970c-f8f8-0577-9dbb164b1180@openvz.org> Date: Mon, 13 Jun 2022 08:35:26 +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 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: <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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vasily Averin Subject: [PATCH mm v4 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Date: Mon, 13 Jun 2022 08:35:26 +0300 Message-ID: <05bcd9df-970c-f8f8-0577-9dbb164b1180@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=fYBLg0GorDblKEye4tioxlFuzZ/2NCtjLKl9KE3W8YI=; b=zIUP7XJmmGybhomix4qhj4dsvVJz3qpTtmJxAHZo+FS3qMKA29sQ0rVxITb06XZqrD nZC+ARODXgb3uW8IID/NoPvHZF9I+vmsgg6S2S3doreOAfToddHYk1Xvd8rWktSA8nfW ahOnjls08LK/iVwueICAsn0ZIC7TfutQY9y1bJsENsR5gcnyHgUNUiHtMrbOcicbvOE2 QVKi01RzoRWCS8SpdjYkxAJRvKM/V18mk3VtVZeCBa7GBMjYuZ9WMAr51wHQPnrptMvn 8xgK0UlON2cwUtsy7uUQEVj443cXKJL8OSjA3MdZI+qOZ/kfjJeo689lqFDEg/SHaxHZ d7mA== 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 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