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 6E61CC433F5 for ; Mon, 30 May 2022 11:26:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09F8A6B0082; Mon, 30 May 2022 07:26:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04D6D6B0083; Mon, 30 May 2022 07:26:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E55F76B0085; Mon, 30 May 2022 07:26:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D860D6B0082 for ; Mon, 30 May 2022 07:26:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A0D1D2112E for ; Mon, 30 May 2022 11:26:11 +0000 (UTC) X-FDA: 79522180542.07.3E13D73 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by imf26.hostedemail.com (Postfix) with ESMTP id 0E7AA14003D for ; Mon, 30 May 2022 11:26:06 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id l13so16182771lfp.11 for ; Mon, 30 May 2022 04:26:10 -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=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=VleSeEOpRENeXIkb3VS63vsilwSdU8qMSP4avGdnDh5rwRnYa2jz2RVYenqeO3pM0E DHnSyyUm/QZ5EmzHYl3Jb+ZfcIpTLRDZmxkC/M0yZtrJnPBT7FMzovaP80spNmx1AGfC YeM+BMD+j8eeiwA3YZgXNeSwjCueUasrWx79lcZTTgD3by9/hKVr+WE8TfaHyDrWDjY7 fvLW1OqA44WVwKYAS5KnteFlnEFDxA/qb7HSBCHdOyxAeCZJXY07V5g1Ad8JgbV1T1LH 9yVcRSF1uk10P9ADPpKBifUv+jJk3ErpO+yVNp/RCuMrSeI9wAh2n2OFB9aEnkWJPam2 Yg4A== 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=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=qQcamTPZ5gH6O9lJTR8h21PAIx6BGHnXnUOH9qEXD+ou9C6ZFZ4P7Tz8dsNnzKAGHJ eB/4gEyUrxjPntC4RRuyib9kc2jsPAkFimf5QZnQ7s9btMkZ8chFUv1BtdeE3extQwTQ yoWYkR/QKEjke6nKibbpWT4WAR97UiBaIskW2bOi1gVLBXphGhrPsxgV5EGcQXhvJdJC Vq63Raj346RNgEw0cUzhl3GCYDAyuOb8Cgfi/ov2izrT6iaJ2/eh15qd9ksNLX+Rfcrc vHa7FvEbinRefkveOoP5n4UyGF6LJdkrFizVnwmvSqP/CqHQdeWaafDUKmKShp/1hzko u28Q== X-Gm-Message-State: AOAM532I6cvJQe+20HNpq0IBMtRcFlFNHZaoNSv/j/5sko6DE/1Y8bmM mQsRXJ4S2acmgUEJ4XmnzsKa3w== X-Google-Smtp-Source: ABdhPJzpWuEoQbBQ6wQAD00lTrkjyUo0hR77U+wtdpC11GHVbqf2v9hXGKCM5qrHCA7Zd3LVUwl52w== X-Received: by 2002:a05:6512:3403:b0:475:afe3:740b with SMTP id i3-20020a056512340300b00475afe3740bmr39209070lfr.436.1653909969542; Mon, 30 May 2022 04:26:09 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id x20-20020a056512079400b0047255d21158sm2253567lfr.135.2022.05.30.04.26.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 04:26:09 -0700 (PDT) Message-ID: <8bb350bb-4109-0065-d95d-bb6777e4391e@openvz.org> Date: Mon, 30 May 2022 14:26:08 +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 3/9] memcg: enable accounting for kernfs iattrs 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0E7AA14003D X-Stat-Signature: nukks4sps37jibgawzxyi337etqxq4n4 X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=VleSeEOp; spf=pass (imf26.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.46 as permitted sender) smtp.mailfrom=vvs@openvz.org; dmarc=pass (policy=none) header.from=openvz.org X-HE-Tag: 1653909966-592191 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_iattrs_cache 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 3ac4191b1c40..40e896c7c86b 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -397,5 +397,6 @@ void __init kernfs_init(void) /* Creates slab cache for kernfs inode attributes */ kernfs_iattrs_cache = kmem_cache_create("kernfs_iattrs_cache", sizeof(struct kernfs_iattrs), - 0, SLAB_PANIC, NULL); + 0, SLAB_PANIC | SLAB_ACCOUNT, + NULL); } -- 2.36.1