Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1032384iob; Fri, 13 May 2022 20:22:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF8PvGbYGxnDESNSkqrb3sSk9AxDDxbYekkM+W8NZByeMN+j9YWwEUUXWKaK/YbEuJrW3i X-Received: by 2002:a5d:43d2:0:b0:20c:b986:a337 with SMTP id v18-20020a5d43d2000000b0020cb986a337mr5813780wrr.445.1652498575207; Fri, 13 May 2022 20:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652498575; cv=none; d=google.com; s=arc-20160816; b=ErjY9h1VcRlFKSJhn5at5KNDEwKJXwcNznCBmECIXq7bhOQmaalfgA8xSk9e1D5Idb Rrzr+YI3cD4cvuaTBAWbw5A9EHnmO04HZA3BKqLfeK1yfbT+t8BrfQk2PAKCTJFWkS/k XPF8sbP6xNl6EbdbM+H9PvpVzDduJrBmTTxrXR9H/r17/KnrgpTee9y3TeiTF+t44jc9 6rc+CSd0jxWkw6ae5OKWAOk6sVINQP//A52AmbbzBaeARK37jng9lrNrNImTq4e0ITyC KFBhontGgq1+O9rMXMQi+vxWfLpey+g6E3wCKds65muWN/OzbRFsxVfTTsU3hLVR9c4k ft2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=B0+ajyKCVT2rz3AxxcmXTaNoUIUvS+gueEimpFPDfFg=; b=t3TFEO9UueK83L0j9Y/4/N9/i0XGysfGwQQH2eMOiqWmkPofGGt6dRebYzECYprWLW DsrM0/LMixii2Dw4PdoK7YiEMqjS14k77sd+9RDlVUauPGEnQ+xg54A13wPae7tlaCz9 vCTjng7nfJubYUfZwaihc5Jep/QCnrhK5tSqc3obtX1W5/kOCst7AngHRQeR9LjE8ajg L4T3v1g7j+L6MRiP3QOh7q8TBF8aeGlrEcia9GGNRdjBcsKgj7dcE1lzU7YkTxgPgphP IrKFl3tJVLhvo8kVugCtME/w1iG49csxqMQj57WVuN0jEleCetR11yqtwzEcJ9BzIniR GB2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="I85v06/Z"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u4-20020a056000160400b0020ac43c9436si4127077wrb.112.2022.05.13.20.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:22:55 -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=@linux.dev header.s=key1 header.b="I85v06/Z"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F45F40282D; Fri, 13 May 2022 17:00:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383173AbiEMRtu (ORCPT + 99 others); Fri, 13 May 2022 13:49:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237670AbiEMRtq (ORCPT ); Fri, 13 May 2022 13:49:46 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0BC3DDEE; Fri, 13 May 2022 10:49:43 -0700 (PDT) Date: Fri, 13 May 2022 10:49:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1652464181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=B0+ajyKCVT2rz3AxxcmXTaNoUIUvS+gueEimpFPDfFg=; b=I85v06/ZEvJcNeiDuoilbejPX0TNHUuErn8RttBrVH5JjU+zsoh88HKy0szjsX39Yi1RsZ In7uhy6gUa1Ho85cugaXKEqwDU+8pfzqbBwhpoRhZrG1XMndLyDa1pMav2wpAm/OLxZQgc 4JdsAOF2NqBN+3cgllWzaU+NIwsQX+o= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Vasily Averin Cc: Shakeel Butt , Michal =?iso-8859-1?Q?Koutn=FD?= , kernel@openvz.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Michal Hocko , cgroups@vger.kernel.org Subject: Re: [PATCH 0/4] memcg: accounting for objects allocated by mkdir cgroup Message-ID: References: <1c14dce9-1981-2690-0e35-58e2d9fbc0da@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c14dce9-1981-2690-0e35-58e2d9fbc0da@openvz.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 On Fri, May 13, 2022 at 06:51:30PM +0300, Vasily Averin wrote: > Below is tracing results of mkdir /sys/fs/cgroup/vvs.test on > 4cpu VM with Fedora and self-complied upstream kernel. The calculations > are not precise, it depends on kernel config options, number of cpus, > enabled controllers, ignores possible page allocations etc. > However this is enough to clarify the general situation: > - Total sum of accounted memory is ~60Kb. > - Accounted only 2 huge percpu allocation marked '=', ~18Kb. > (and can be 0 without memory controller) > - kernfs nodes and iattrs are among the main memory consumers. > they are marked '+' to be accounted. > - cgroup_mkdir always allocates 4Kb, > so I think it should be accounted first too. > - mem_cgroup_css_alloc allocations consumes 10K, > it's enough to be accounted, especially for VMs with 1-2 CPUs > - Almost all other allocations are quite small and can be ignored. > Exceptions are percpu allocations in alloc_fair_sched_group(), > this can consume a significant amount of memory on nodes > with multiple processors. > - kernfs nodes consumes ~6Kb memory inside simple_xattr_set() > and simple_xattr_alloc(). This is quite high numbers, > but is not critical, and I think we can ignore it at the moment. > - If all proposed memory will be accounted it gives us ~47Kb, > or ~75% of all allocated memory. > > number bytes $1*$2 sum note call_site > of alloc > allocs > ------------------------------------------------------------ > 1 14448 14448 14448 = percpu_alloc_percpu: > 1 8192 8192 22640 + (mem_cgroup_css_alloc+0x54) > 49 128 6272 28912 + (__kernfs_new_node+0x4e) > 49 96 4704 33616 ? (simple_xattr_alloc+0x2c) > 49 88 4312 37928 + (__kernfs_iattrs+0x56) > 1 4096 4096 42024 + (cgroup_mkdir+0xc7) > 1 3840 3840 45864 = percpu_alloc_percpu: > 4 512 2048 47912 + (alloc_fair_sched_group+0x166) > 4 512 2048 49960 + (alloc_fair_sched_group+0x139) > 1 2048 2048 52008 + (mem_cgroup_css_alloc+0x109) > 49 32 1568 53576 ? (simple_xattr_set+0x5b) > 2 584 1168 54744 (radix_tree_node_alloc.constprop.0+0x8d) > 1 1024 1024 55768 (cpuset_css_alloc+0x30) > 1 1024 1024 56792 (alloc_shrinker_info+0x79) > 1 768 768 57560 percpu_alloc_percpu: > 1 640 640 58200 (sched_create_group+0x1c) > 33 16 528 58728 (__kernfs_new_node+0x31) > 1 512 512 59240 (pids_css_alloc+0x1b) > 1 512 512 59752 (blkcg_css_alloc+0x39) > 9 48 432 60184 percpu_alloc_percpu: > 13 32 416 60600 (__kernfs_new_node+0x31) > 1 384 384 60984 percpu_alloc_percpu: > 1 256 256 61240 (perf_cgroup_css_alloc+0x1c) > 1 192 192 61432 percpu_alloc_percpu: > 1 64 64 61496 (mem_cgroup_css_alloc+0x363) > 1 32 32 61528 (ioprio_alloc_cpd+0x39) > 1 32 32 61560 (ioc_cpd_alloc+0x39) > 1 32 32 61592 (blkcg_css_alloc+0x6b) > 1 32 32 61624 (alloc_fair_sched_group+0x52) > 1 32 32 61656 (alloc_fair_sched_group+0x2e) > 3 8 24 61680 (__kernfs_new_node+0x31) > 3 8 24 61704 (alloc_cpumask_var_node+0x1b) > 1 24 24 61728 percpu_alloc_percpu: > > This patch-set enables accounting for required resources. > I would like to discuss the patches with cgroup developers and maintainers, > then I'm going re-send approved patches to subsystem maintainers. Hi Vasily! Thank you for the analysis and for the series. It looks really good to me. Please, feel free to add Reviewed-by: Roman Gushchin for the whole series. Thanks!