Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1481589imn; Sun, 31 Jul 2022 08:38:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lzTBNkEfXWfO+eNmNDmpYZyzujP4/12LnZbm866trTfKRVEl0lQa6pPJ0mvUVC3FL4hW4 X-Received: by 2002:a17:90b:1643:b0:1f2:46cd:9047 with SMTP id il3-20020a17090b164300b001f246cd9047mr14327321pjb.140.1659281926998; Sun, 31 Jul 2022 08:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659281926; cv=none; d=google.com; s=arc-20160816; b=D0dG2PiRo5Ewbm30eP91QJ0G9O+AmTdNTFlq6OC6FEoSLJhWZb5lnd5c4qnUYaA0BO EFNLgxcoGPzzqLQLzZTOWp7s+iPS78HdSoyW+U5VVgJblN8WanGXyBZCdZc3AzujUgag qVe2VM00LsU4to6HOIPBsAgk5PI4RF5ow7KztJc8pBKNWcea8CTOnQxlHCLzs2MMW9Op 8IvTUGciuZr2Sa+wwlhlBhwrntyBBI/sQBRd+FqzTAwo8Toe6T7Mcne1Sh69teaEz9Tu rCoEqbnn5Gft8vKeqXqu8Y30Dbv0s1t373SrDySX5QTuDG9Z89gynYr6HU+KheAX4L3Z FnLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:dkim-signature; bh=BQjoBYdrvkmgbq96aMuVIReKVBshDEV9OFCA7cFNc1M=; b=QkCLITrZrlCR5DvnaKjvhO/HpRs2wLFpnIpvsHGA6Xglhd/Ydy4s3gEX45HbH4zf9C GSOSh/BGeyosBy9VGrlDx4Typ5FsRJESRFS42mlI+MPdI8WO6A/ZMw2pran+QWmrnlCv i/Md53mPUoThETup0WFTd9Dggwag7HHVQc3XNOQakyZxT6spP2j3wHL4roPiM6QYDbJJ mik6Is0+ZLoiBB4+uoIX1rIGrG3mA1GUFDhidLBtuYS3NMKxtU2E2kB5E6gBiepocnug /QfzHmvfa/DPY3QjqueTp7/hl+8dewPz9xg6YDwElrWiYdxD9KlwwKhfM4Q/9u+6AvhN LmCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=tQY4M9GM; 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 t17-20020a170902b21100b0016ee32d255bsi2035308plr.410.2022.07.31.08.38.32; Sun, 31 Jul 2022 08:38:46 -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=tQY4M9GM; 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 S235899AbiGaPha (ORCPT + 99 others); Sun, 31 Jul 2022 11:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233765AbiGaPhZ (ORCPT ); Sun, 31 Jul 2022 11:37:25 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7BCE08A for ; Sun, 31 Jul 2022 08:37:23 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id r14so9850196ljp.2 for ; Sun, 31 Jul 2022 08:37:23 -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 :content-language:content-transfer-encoding; bh=BQjoBYdrvkmgbq96aMuVIReKVBshDEV9OFCA7cFNc1M=; b=tQY4M9GMZNIrSmoAqqmwqT2VSKU0vLcY1uwsucKmjNWQei/KcUA+cmdJhWHN0i9bu+ NlrM1hw+FICYy0a21p0JPU/igcYzHVlEuPTkPtLnqV/iAgdHjVTqe45MsEkuTSvdjNj3 +rTSlYP5iNfkhrn1hjrqjewu7HTGjhEbdFVvdIYy/kCZon3yM270rADqroIoMyv6pNCp GYhpghRHIBfAcHsqTRHdHa8EBkcp548y/VH+I3G0jllN/0WWLh5XAVSZRn+oSaOl07qe /rzYTPTIVMuT+4aSOuZHCo680h0fSKqs+Yk9BpSznoVqpcZV2gYjAGC8ceOrEuTy4/Ci 37mQ== 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:content-language:content-transfer-encoding; bh=BQjoBYdrvkmgbq96aMuVIReKVBshDEV9OFCA7cFNc1M=; b=k63c99tpEDdmRKgaKIFmIfIXrLk6FMekphkQbWReUdAY5JYb8a+XhIUijx5riveVSU LcbVk+I7BINmgTp4SEyPb7NwxovzD/1Wl+ZAbBLh8uMuQjqiJLpBZEHNtcmwcywmoXDj GNfwuRz96OZieZnosGZdaYKvZgymn9gDBRvofBFjCBPp0xtlObUkkbNXEcWLKjn3Y7OI 7Jkj0X2iIJYjYpybv1jalJ5nMDXDwmQmVSAGvUYXQTq9hpHdhab5ixZO/BLEn0jR8RT+ dZNgrYxvRWdZB58hNtaARFAQkSSUeLfoAri73rHGwS3xw43/5ufa1/JgHOOW1upKKf05 mHlQ== X-Gm-Message-State: AJIora9k+KTULSskFX8GSq0BUWooxQKvqBCGUBllYrCo7CWpfPr+LKBP vyWIzTHW0z1khWhC1/z5az1Xuw== X-Received: by 2002:a2e:3109:0:b0:25a:8a0c:40e2 with SMTP id x9-20020a2e3109000000b0025a8a0c40e2mr3713067ljx.26.1659281842217; Sun, 31 Jul 2022 08:37:22 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.143]) by smtp.gmail.com with ESMTPSA id u6-20020ac251c6000000b0048a97b0373bsm1378816lfm.59.2022.07.31.08.37.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 Jul 2022 08:37:21 -0700 (PDT) Message-ID: <43433a5f-cfbb-7aa1-5054-08704faabae9@openvz.org> Date: Sun, 31 Jul 2022 18:37:21 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Vasily Averin Subject: [PATCH 1/3] memcg: enable accounting for kernfs nodes To: Greg Kroah-Hartman , Tejun Heo Cc: Alexander Viro , linux-kernel@vger.kernel.org, kernel@openvz.org, Shakeel Butt , Roman Gushchin , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Muchun Song , Michal Hocko Content-Language: en-US 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,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 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.25.1