Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3876614ioo; Mon, 30 May 2022 11:47:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8dLoHrA/qamBhqQCl1QNNWipXL7VhxRiGqoeb2Qi5xrXVx6XDkuwTZEE78cxEXtCBqWmm X-Received: by 2002:a05:6402:1f03:b0:42b:38ed:a9ff with SMTP id b3-20020a0564021f0300b0042b38eda9ffmr38282337edb.218.1653936450704; Mon, 30 May 2022 11:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653936450; cv=none; d=google.com; s=arc-20160816; b=npve2z/bToLdBnQ9DhssZp/DKobc1Pehx7YlGKPZqyDRVfH0oeRZ7zUdeATEBedWQ0 P9MfI/HOcOGJsl+OSTN+eafHlbqeeWSRotuX4jHA2joVFvlwzZQ6JomSMXstoqirzwtq Trj0pqOZv9sjNZcv3NFbZ5GwF5aGO5G6jxQTYFK2xClo0Gd0WFl07lb1xB0sL/IKdLVO s6YJciRMLORLkZSjEUBcQxL/ACUBJH1KOM/cpjjau9m54pWl0ZrfjoghSNayVpXzaM6o YEGqut4pahEBncg9TnhwjzhBXkvsYp1xQGdGosRwdzheKp04aq+vWQaAsTXaa0BVfVNX MCzw== 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=IK1h75QrK4dLAeCcHF6vHO4eDXNyXwLtZQJf9O+8m78=; b=IN5QrPYozIZWHMAh09m6mn3sC2JlxUvlGhsJ5MfBkpboL8nM6S7KTkTZ+uAzVMn0Xq 0Rhb/Wi2RpBMfDwo4ZCKrFiF7Q+spSY0LV/qYRNnQUJSxk95AiyMS6VIjUJ/EkaQ5MZ7 02OOc79xTIGZHBOOt+7c7P65sL6KX72XmiWA+sIeMbDOEekQI8edoi499PptHBm5Sm3N w0k9ip0AUUOPW6orc1aeHAwEnKmQG+U1ave4Dr1J2zrmGPvhyDzYeDnRJh3C6DjYjRjs VxZ1JCfTow6RifaQcdTpUKOTjtdO5o3Qan9l/cQN3A9GAZPTkIZjDS4fZHJiz4Umy8ym O0Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=XPNvq5Nb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd37-20020a17090762a500b006f4f92db142si12763650ejc.635.2022.05.30.11.47.04; Mon, 30 May 2022 11:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=XPNvq5Nb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234038AbiE3LZx (ORCPT + 99 others); Mon, 30 May 2022 07:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235665AbiE3LZu (ORCPT ); Mon, 30 May 2022 07:25:50 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C85767DE10 for ; Mon, 30 May 2022 04:25:48 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id u30so16212276lfm.9 for ; Mon, 30 May 2022 04:25:48 -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=IK1h75QrK4dLAeCcHF6vHO4eDXNyXwLtZQJf9O+8m78=; b=XPNvq5NbB2kQePetWgiJpCVF9J44XxrjS/Fy/stHVxJC8lmeUymcBCUm67p4d1i4cZ qnXlnY6v2ktg2Yxt9sZ7Qb5LQooZmoGKsQkH4KxqykKI/mPw6t3xpTHDkwkG0hWfB4mS 6P7rjpWQ/xXC3Uj/qVEsuI/XpPeotY6Mon2SrfSTES1WWK2jh5LcRYYuBCaW3sA28sqB /7wJCIyZKMIn86gR9iZ0rN0ZrA2wz5667OJEMKgDBsFCR5bK6mo5YOtmADsqmMBbeoZ0 X9zJe7NDh4yO3uILPz/BLIkNy0JCVPgedXFPhYxZ51dXuoXgH1/QHI+8g9nl2zeyeQco 88hQ== 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=IK1h75QrK4dLAeCcHF6vHO4eDXNyXwLtZQJf9O+8m78=; b=sk4Pw0jUSevhvRPQMQmz5s5aDmNs+bvpTKv0VMXLEJlLP2ZZQOH2Fso3WW/VNE29I7 CBNVRVwrn1CH0fIl9+Nyl6YLeYH0w1zKydHuHa+VfJcyO0moz4NigxHnGoaELpxp55E0 Vzejhm0kA0nLJ2zkLeQ7D9rDja/dej0aRQVkxJWrjd7zeLc72kpQofAEyZ06faRK8s6E r0iX+clXiEk0c//nYwgIsG41cFh8rOZPJLMFGaYQul5lV3OvdKGMjEUCeuZ7PKmEVQHI Mkdw5/hvZ0nmzg+eDeJ2s2htG7FuDGpMLv3vc38ra8CE4wg4f6PfuSKOZN0CWRRam8AT UUtw== X-Gm-Message-State: AOAM530EGUjeLNhDH3hH6VuW99IAVFZh3f8CuuYM08kc2MfIL9tQ0KCI i6xh4h/7xgLAXYBcsTYhE7BFdw== X-Received: by 2002:a05:6512:3092:b0:478:786f:9fc0 with SMTP id z18-20020a056512309200b00478786f9fc0mr25734944lfd.562.1653909947060; Mon, 30 May 2022 04:25:47 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id y26-20020a05651c107a00b00253bb2564cbsm1404094ljm.134.2022.05.30.04.25.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 04:25:46 -0700 (PDT) Message-ID: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Date: Mon, 30 May 2022 14:25:45 +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 v3 0/9] memcg: accounting for objects allocated by mkdir cgroup 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: <06505918-3b8a-0ad5-5951-89ecb510138e@openvz.org> Content-Language: en-US In-Reply-To: <06505918-3b8a-0ad5-5951-89ecb510138e@openvz.org> 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,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. All allocations are splited into: - common part, always called for each cgroup type - per-cgroup allocations In each group we consider 2 corner cases: - usual allocations, important for 1-2 CPU nodes/Vms - percpu allocations, important for 'big irons' common part: ~11Kb + 318 bytes percpu memcg: ~17Kb + 4692 bytes percpu cpu: ~2.5Kb + 1036 bytes percpu cpuset: ~3Kb + 12 bytes percpu blkcg: ~3Kb + 12 bytes percpu pid: ~1.5Kb + 12 bytes percpu perf: ~320b + 60 bytes percpu ------------------------------------------- total: ~38Kb + 6142 bytes percpu currently accounted: 4668 bytes percpu - it's important to account usual allocations called in common part, because almost all of cgroup-specific allocations are small. One exception here is memory cgroup, it allocates a few huge objects that should be accounted. - Percpu allocation called in common part, in memcg and cpu cgroups should be accounted, rest ones are small an can be ignored. - KERNFS objects are allocated both in common part and in most of cgroups Details can be found here: https://lore.kernel.org/all/d28233ee-bccb-7bc3-c2ec-461fd7f95e6a@openvz.org/ I checked other cgroups types was found that they all can be ignored. Additionally I found allocation of struct rt_rq called in cpu cgroup if CONFIG_RT_GROUP_SCHED was enabled, it allocates huge (~1700 bytes) percpu structure and should be accounted too. v3: 1) re-based to current upstream (v5.18-11267-gb00ed48bb0a7) 2) fixed few typos 3) added received approvals v2: 1) re-split to simplify possible bisect, re-ordered 2) added accounting for percpu psi_group_cpu and cgroup_rstat_cpu, allocated in common part 3) added accounting for percpu allocation of struct rt_rq (actual if CONFIG_RT_GROUP_SCHED is enabled) 4) improved patches descriptions Vasily Averin (9): memcg: enable accounting for struct cgroup memcg: enable accounting for kernfs nodes memcg: enable accounting for kernfs iattrs memcg: enable accounting for struct simple_xattr memcg: enable accounting for percpu allocation of struct psi_group_cpu memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu memcg: enable accounting for large allocations in mem_cgroup_css_alloc memcg: enable accounting for allocations in alloc_fair_sched_group memcg: enable accounting for perpu allocation of struct rt_rq fs/kernfs/mount.c | 6 ++++-- fs/xattr.c | 2 +- kernel/cgroup/cgroup.c | 2 +- kernel/cgroup/rstat.c | 3 ++- kernel/sched/fair.c | 4 ++-- kernel/sched/psi.c | 3 ++- kernel/sched/rt.c | 2 +- mm/memcontrol.c | 4 ++-- 8 files changed, 15 insertions(+), 11 deletions(-) -- 2.36.1