From patchwork Sat May 21 16:37:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12857958 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 7415CC433EF for ; Sat, 21 May 2022 16:38:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0879A6B0080; Sat, 21 May 2022 12:38:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0106A6B0081; Sat, 21 May 2022 12:38:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF3086B0082; Sat, 21 May 2022 12:38:02 -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 C99436B0080 for ; Sat, 21 May 2022 12:38:02 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AB0EB7DC for ; Sat, 21 May 2022 16:38:02 +0000 (UTC) X-FDA: 79490307204.15.25412DF Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by imf03.hostedemail.com (Postfix) with ESMTP id C40CF200D6 for ; Sat, 21 May 2022 16:37:50 +0000 (UTC) Received: by mail-lj1-f179.google.com with SMTP id v9so3386723lja.12 for ; Sat, 21 May 2022 09:38:01 -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=WXL0Kr6NJlPCFE6AkYnbXRqpsriCeDIrboyr2mKYIIo=; b=azl0IXyBsAkxqX4vnBtqgFslhmNTs6lzDHtxK88VAXLucBey8Th1FgJxUa7U3KmkKX a2cSakrrd3z88D0GZSsfoNCi+sxTt7Cs1SfxFhkIEMrifezGXM/r9N8lfLaGjdnMrnbS lxJ6kBnqXJk8dTeheK+GNRV0GcO697RcNQXy8Rh1czDZ+fZQV/SnLAWYNvakQ6NNyqxI 2mqNYy+/djuO3FLdUA/Qtk90HJNw/IseTJqpAm8vYbpT8jO1zHtXLaI1SjfUbas0SsY+ sHpo/9jWTXqp52j71o/GX18cDRYXA9Q4eqP/cXswFRq2wO9pAWMI6JaDPuxCUeyCjq7E 0ROQ== 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=WXL0Kr6NJlPCFE6AkYnbXRqpsriCeDIrboyr2mKYIIo=; b=NUkgoJK+/pGLWMRSzx9+WmlTKhsb0zQtMLTJrl9wO9nfBe1xnURnhE/Dk0Y8kJl33U 8PPcskfw3q8e4f+p5tuJxjxuC6k+VTOM4CMW5axR/d59mg678OTMESnD1+ndnTP3ZZMm Gu2chcdd+LZkVLbbSBqQCY5Sg9xncJXUy21J1ZpzRarqI9A9Zmt30KkCOGjP1+0fgTfL CU5erFmGxmDQ/yoDPlC5KEX145GKePhx6PuNB/3owtI36AmYuBvLyogEnr0NvVqba7ky rFI12QEMgmrB/jNg+o3fgQGiBZr7MqwQ0dCZ0nOPgj4WBuMhe2HwNvcMSx0JB2pyGa5L M6cg== X-Gm-Message-State: AOAM5327UhfRjp6q4iezKUlgRqVe/bs9gizjTfPpYWPZ3u+r8DDA3A6H XeRedrPe3fhCy9tM3OKIqW7cmA== X-Google-Smtp-Source: ABdhPJz9guAKE14vLO2t185SB1774V0K9APnw2MBpEnkasC6qr9TkZkPhtlY2NCcTThOGAH/Yv6RAQ== X-Received: by 2002:a05:651c:890:b0:248:5819:b949 with SMTP id d16-20020a05651c089000b002485819b949mr8442007ljq.476.1653151080713; Sat, 21 May 2022 09:38:00 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.185]) by smtp.gmail.com with ESMTPSA id d19-20020a2e3313000000b0024b14fa6061sm772690ljc.1.2022.05.21.09.37.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 May 2022 09:38:00 -0700 (PDT) Message-ID: Date: Sat, 21 May 2022 19:37:59 +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 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 , cgroups@vger.kernel.org References: Content-Language: en-US In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C40CF200D6 X-Stat-Signature: ygg6z6h9pwq39zx9sc5eeqg8uacsng9e X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=azl0IXyB; spf=pass (imf03.hostedemail.com: domain of vvs@openvz.org designates 209.85.208.179 as permitted sender) smtp.mailfrom=vvs@openvz.org; dmarc=pass (policy=none) header.from=openvz.org X-HE-Tag: 1653151070-703414 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); }