Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3245869lfo; Sun, 22 May 2022 23:46:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFya/822/HGmKqhTM4fUUvegwoMNBoegos9pDofyx1dIOnIpPs0YzfQYZErGvx1tvkEhaT X-Received: by 2002:a65:5c48:0:b0:382:2c7:28e9 with SMTP id v8-20020a655c48000000b0038202c728e9mr19414392pgr.472.1653288385173; Sun, 22 May 2022 23:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653288385; cv=none; d=google.com; s=arc-20160816; b=G5WLugdyIdRe1krY0rQ0xnvriCDfkoSLeoxE0vWNngGtrzm8UIBi8Q/oeY4ikIEDJz rgUUWbiqDnzXgeTdq3O+jn0DRszoWjBz4TA4UNabY+gbNp2tLTEjwORaMdtvXS3xovjP XDSrTGpkE8ny8dglNgLGwIDgaMsRLWDRnGTp6EHB/KQORsCjbm7Vgx6BAb56+qp69oIM x8B8Ni6EtkgodBn6njdL2Mzy6+rpEX/Jro7ipGuI60dVFBTd4+ZhV/XJsLysU1zUcSi7 9SWx2DqQj2hJiFhw8hHpKk6RkOOQTwfimym+noCUTimUWzzVE3zxYdBXkz95wStynpxV w4yw== 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=IVDqiXzI4dIEBMTsaaQRM7ta9ARirhRNc6apB4FJmT4=; b=GEyD1/wg0733tQ/+bDqNOi30n4nZ2NI7baJitviVThg6k0CGHJ6rr1K8/3pF1YsXjr xZhOLiz16JLUwCLJn9TiG9bYkZslX0vgvTfUxhuGdVLEPcvXTNFDD1xmmMFQZmDGBQBJ PizeqomcY+1K1BXjWikzrSfoH98irNfJzYFj9mYJKsmQ0wuu33xZbgxBG2cZfNFtNsUY ZnyhxWwQr9PHiBr57No4jrzJHGwK1i9g1kMybWcHe25913cyYlHEX4dLwuz4Ek2GTdaH HTHzkjmo9ei3o4mOCJPaVYogaasJ0Ad+DgArcPIgojw+I2CgqdP+i/lGJf6tnnitRIAa Tvig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=EtLP8pxV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id lk18-20020a17090b33d200b001dbc8281abesi13730747pjb.178.2022.05.22.23.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:46:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=EtLP8pxV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9BA321FA76; Sun, 22 May 2022 23:16:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343505AbiEUQhz (ORCPT + 99 others); Sat, 21 May 2022 12:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349958AbiEUQhw (ORCPT ); Sat, 21 May 2022 12:37:52 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB5E61616 for ; Sat, 21 May 2022 09:37:50 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id v9so3386162lja.12 for ; Sat, 21 May 2022 09:37:50 -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=lhPV+mtMMtyLLxfX7TCpk/hd8pUN+bouJvTC82Bf6vrAu24CCgARzRAw9+xD9A7d+N F/LXSaOy1VU+qJ11G6tskSF0MF5htOBolCY9CstO8bI2WKHMvVeSKXzlq/rAsOEcqapE p2Yglayk4zbNPM2smVRcVY9+p8deX5ZdPCgYfhaUNVw4rADCQEWKLmBRGvrV9LkODXmF pDLuqJhAjhi9w4OVz2rvWcgHg87QvavS7cDwlBNrMpT5Pjy/HtDR8FLeY7Wadj1WeaRH lgBGGxnDtzE5Ggzc8H+Pd30CsvcQYQZ/zPpq5xU7ESGo4qW5FBDUNNpDi5SLdeQm8CXd fwnw== X-Gm-Message-State: AOAM530ip9yCqnbn34jKXJkVmoflLAoCfZ8QXgXQpgkXF5OUWuJIQO5L YH6HOTUZMmfKXeUFaKkP+HQjhA== 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 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 --- 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