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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA2B0C433EF for ; Thu, 23 Jun 2022 14:50:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C6D28E015A; Thu, 23 Jun 2022 10:50:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 575758E0144; Thu, 23 Jun 2022 10:50:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43E4F8E015A; Thu, 23 Jun 2022 10:50:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 368A38E0144 for ; Thu, 23 Jun 2022 10:50:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 061FC34429 for ; Thu, 23 Jun 2022 14:50:59 +0000 (UTC) X-FDA: 79609787838.23.46CAE21 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf19.hostedemail.com (Postfix) with ESMTP id A00961A001B for ; Thu, 23 Jun 2022 14:50:58 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id f39so18151289lfv.3 for ; Thu, 23 Jun 2022 07:50:58 -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=gx5BulmdWVt1E6J23Q6sWTUkZpDqVLFQzvPT6hFPLlw=; b=zFPWnFhORhhkx+K6C2WQvQM0YSy+ZbfRPmzcQLsty0RSOgd+5dgld9MCRIQ56cNSRK BCnClixQqpL7OFP/+tRWG1VBGjAlAcE8nDR1yKu9FAfO39DLsaWvqo7E8phYLKhdHn5x /OnNOgxfX3uytsUOosIdIHz6LvZu6wTX+qQEK1PEN6Py9mGCUTJEWhQ827qs34DAAMD7 lNFvFBB1BJqKZEBaIHQJG/Ip0/M4QLNQdIh00w//KELVSTh4dbSVMXiXkhuSlhcBwSyp OdEG1BVxEEkxeYlEP/S71/GXCS8L542kaiqVa6Ghai1qeB/4D4YZWX3qHzUD0YsJcJ/M aSAw== 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=gx5BulmdWVt1E6J23Q6sWTUkZpDqVLFQzvPT6hFPLlw=; b=uy3VKQJ/r36iub/xsCPtK5ykrMe77Vmo4wqAkLzLz+Ou4Xq46l8zWwqpvdw6VWyz8r YC7L4yLDRtOx323xNzfJdoUF+JptupbobSLNngXAWWz2XEQIBKjxsT5gt+NhXoLMVJiL qRIitoICJQmZcS5z4hQuv25zglKC6o3N7Cao9eHpthYHeQkc5RKIX0av3/lk9KC14oIF mPbbB8hqQMehpX4WUNLJtSRmiqIhGJ1dwXyMo6x6l52X8ifXi0t9ph/6QpTTRsmuYSsY sqx5WkddS8Jv0Few4XRIjNzEJapP/yS3IgzfHWoC3/KgM/DKziWMaioOMoSXD5QZOJft vpGg== X-Gm-Message-State: AJIora959Ef2tEBEFo1n/ORp5BSvAtBmSCBMZC0k8R1xd/ZtPtSq0gkl N5I0J8ziBe05KL3ZytMPwUiGcw== X-Google-Smtp-Source: AGRyM1uTnBSEDsDu11OjnHjb3FojldgzsC1VUsNRLNFNCtzVtvGbYs9IJOhajOCoRwBTb/baBFXjSQ== X-Received: by 2002:a05:6512:3b21:b0:47f:665a:bf50 with SMTP id f33-20020a0565123b2100b0047f665abf50mr5720843lfv.673.1655995857250; Thu, 23 Jun 2022 07:50:57 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id i8-20020a2ea228000000b0025a59470621sm490327ljm.26.2022.06.23.07.50.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 07:50:56 -0700 (PDT) Message-ID: <58cbf16e-ae4a-b6c5-f2ef-ab9fb3d29baf@openvz.org> Date: Thu, 23 Jun 2022 17:50:56 +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 v5 2/9] memcg: enable accounting for kernfs nodes 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: <4e685057-b07d-745d-fdaa-1a6a5a681060@openvz.org> Content-Language: en-US In-Reply-To: <4e685057-b07d-745d-fdaa-1a6a5a681060@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=zFPWnFhO; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf19.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.54 as permitted sender) smtp.mailfrom=vvs@openvz.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655995858; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gx5BulmdWVt1E6J23Q6sWTUkZpDqVLFQzvPT6hFPLlw=; b=anWdrlzpcsCcMYSgPA5nxVsBPmNfA+3kgWDGVlKriwBUPplOjNQjbDkskvwv4F4CCS3kLT bUcX0UoMZke+5J42wuLEdikEp6DkqsENrV29la5GH5UPsw1DUCuWctsXzUFgIFLpuUNLh9 7wvETk+aRIUN4fTHdEI1R7n/OdVs1qA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655995858; a=rsa-sha256; cv=none; b=wrJHWzw4T/LNE3QBk7jRxI4bDqKyQTUwzkgV3dGx7preP9UVJNzmedPN4+VV26MGQlb/9r CFyOPVjmefdQLSIZ1N8y9+11VNWPzaWtpMc5gWB87Ou9MDxOeS3eY3rpezOpI6LfTWQo4N FZ08Et9ogclr0zB3RMz1X4ueTUcvYTM= X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: A00961A001B X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=zFPWnFhO; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf19.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.54 as permitted sender) smtp.mailfrom=vvs@openvz.org X-Stat-Signature: s8ssf1sayi3pfrzd5p5ihtfhf9bxtdkw X-HE-Tag: 1655995858-812860 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: kernfs nodes are quite small kernel objects, however there are few scenarios where it consumes significant piece of all allocated memory: 1) creating a new netdevice allocates ~50Kb of memory, where ~10Kb was allocated for 80+ kernfs nodes. 2) cgroupv2 mkdir allocates ~60Kb of memory, ~10Kb of them are kernfs structures. 3) Shakeel Butt reports that Google has workloads which create 100s of subcontainers and they have observed high system overhead without memcg accounting of kernfs. Usually new kernfs node creates few other objects: Allocs Alloc Allocation number size -------------------------------------------- 1 + 128 (__kernfs_new_node+0x4d) kernfs node 1 + 88 (__kernfs_iattrs+0x57) kernfs iattrs 1 + 96 (simple_xattr_alloc+0x28) simple_xattr, can grow over 4Kb 1 32 (simple_xattr_set+0x59) 1 8 (__kernfs_new_node+0x30) '+' -- to be accounted This patch enables accounting for kernfs nodes slab cache. Signed-off-by: Vasily Averin Reviewed-by: Roman Gushchin Reviewed-by: Michal Koutný Acked-by: Shakeel Butt Reviewed-by: Muchun Song --- fs/kernfs/mount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index cfa79715fc1a..3ac4191b1c40 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -391,7 +391,8 @@ void __init kernfs_init(void) { kernfs_node_cache = kmem_cache_create("kernfs_node_cache", sizeof(struct kernfs_node), - 0, SLAB_PANIC, NULL); + 0, SLAB_PANIC | SLAB_ACCOUNT, + NULL); /* Creates slab cache for kernfs inode attributes */ kernfs_iattrs_cache = kmem_cache_create("kernfs_iattrs_cache", -- 2.36.1