From patchwork Sat May 21 16:37:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12857957 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 2E2FBC433F5 for ; Sat, 21 May 2022 16:37:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9B806B007D; Sat, 21 May 2022 12:37:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A234F6B007E; Sat, 21 May 2022 12:37:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89CBE6B0080; Sat, 21 May 2022 12:37:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 738CD6B007D for ; Sat, 21 May 2022 12:37:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4F52733919 for ; Sat, 21 May 2022 16:37:52 +0000 (UTC) X-FDA: 79490306784.21.730396F Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by imf09.hostedemail.com (Postfix) with ESMTP id 7BACB14001D for ; Sat, 21 May 2022 16:37:40 +0000 (UTC) Received: by mail-lj1-f171.google.com with SMTP id s5so12624350ljd.10 for ; Sat, 21 May 2022 09:37:51 -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=IVDqiXzI4dIEBMTsaaQRM7ta9ARirhRNc6apB4FJmT4=; b=EtLP8pxVwmIKt66WFCvOclrJgEDpp4X1B1T1JnZ7B39hZcHA/QLCYXBWJxjJd8pcIn lPowuGK/5K7RomQjyNJyh25sw01fJiLswg8uBKe7UwNYxrTR/UYqixFMFH9Kg3zSr8o0 kA5sXr7Clen8UoGgs9FvZsKN2VPvgHy2ziuaqbmxMaS7uHK1gl8pK6fP/ymVim8sU6Zr BKqoipnZGWxy1V2JtyXxotPu0Iycs57GEAoUef3xEuleqmg+XkokIek+j2p/XY6v1PAK zkwFtJ4C3Tkwhu0SAOsQv0JgOS6cceETuFVTySGKI/A/j54qwu1CQneG+vRqOvOqUVA1 cJ3w== 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=IVDqiXzI4dIEBMTsaaQRM7ta9ARirhRNc6apB4FJmT4=; b=IbEsbaQRt/vnrEUtUAxGsYOTmKogVDnp1miz6D0qNsTX7UtZZCcHllHfgHMUCFV1Jk l/hOAhx/DVoUrHn0Yw2y2wzUDWVSph8PJpTYkHkB97ikZfOkw1oTfrhRCzs/0bJMJ2sN dBr1bGsqFrESJqVHlwLkVeeXwXpOCgC2RpvviBOke1r00nTvQAQCdeui+1JyOXZJeo+r N1AARYlRxvUcBnyyclPY3RRECt4FjE+580X3P9FIQoL8QShTOXdlPDgC1+HcOlvdICEj +RKh3p3loS5tcJnJ687iVN54yg78ykjGG+mktPxXPQKeS/RC9j01xYbtzLaED3NoBvr4 QjKw== X-Gm-Message-State: AOAM531LP9dmOsE7/1iO+QZzXBpNNOLzrAPEogNjbfWGYw0JgzxRlyKx NqmSQS5kfBE3ARaZvEwwUj4n3FAzz8khcQ== X-Google-Smtp-Source: ABdhPJwTeHS4NovOhmuXmVJAEPnop69XY0S2sk+u6JhnkIHtEODDGFf4FcjmtHxM/Xhv4BUHh0QVsQ== X-Received: by 2002:a2e:96d2:0:b0:253:d8f1:66f8 with SMTP id d18-20020a2e96d2000000b00253d8f166f8mr6552746ljj.321.1653151070521; Sat, 21 May 2022 09:37:50 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.185]) by smtp.gmail.com with ESMTPSA id w11-20020a05651c102b00b0024f3d1daebasm749238ljm.66.2022.05.21.09.37.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 May 2022 09:37:50 -0700 (PDT) Message-ID: <4f129690-88fe-18f2-2142-b179a804924b@openvz.org> Date: Sat, 21 May 2022 19:37:49 +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 v2 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 , cgroups@vger.kernel.org References: Content-Language: en-US In-Reply-To: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7BACB14001D X-Stat-Signature: oqdejxo687resi7y3qdoc56jym9zoyxx X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=EtLP8pxV; spf=pass (imf09.hostedemail.com: domain of vvs@openvz.org designates 209.85.208.171 as permitted sender) smtp.mailfrom=vvs@openvz.org; dmarc=pass (policy=none) header.from=openvz.org X-HE-Tag: 1653151060-614076 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",