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 EDF97C433EF for ; Mon, 13 Jun 2022 05:35:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 823D68D0152; Mon, 13 Jun 2022 01:35:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 785408D0142; Mon, 13 Jun 2022 01:35:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FF8E8D0152; Mon, 13 Jun 2022 01:35:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4BB478D0142 for ; Mon, 13 Jun 2022 01:35:02 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1BFBD60DF5 for ; Mon, 13 Jun 2022 05:35:02 +0000 (UTC) X-FDA: 79572098844.09.4C62961 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf07.hostedemail.com (Postfix) with ESMTP id 7DBE840071 for ; Mon, 13 Jun 2022 05:35:01 +0000 (UTC) Received: by mail-lf1-f48.google.com with SMTP id c2so7189729lfk.0 for ; Sun, 12 Jun 2022 22:35: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=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=poLeG6zhCv/e/uvaonfvqyZcWLUQoZKI6x1zrBYzR8yEcLqX5MJjRu0DpBmK0UieGM 9s8GkMwlIhLIZoQPjVePmWg9+eHaw3B/mxAbv92cla9k0nTwF0/t7OND21vBl/jnCbIU IRCipafuU6E/GhmoUqu9xNvZBtbB5Z528WMihwahUcILGFkidaBexjc14Cq8pW8Z7Pvj N7AfutKNP8hBX8d3mBRFD1w6M6/KhKiGE+zL5Mh/NHBVYzb1srbsoyGopRzu/uGFFuO0 9CT6RkUDfugqIiBXyVg6DD3bipqyjO7hrVYqc1/pWq903VKpx9vz96zgU+w6o/ZlFCvC 9x1A== 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=EIMEgnGqjw6pLRMHLvB+zmEI8LliT2/0Fbuyf7ZqcFMvvF5C5v2V4uU0GVOxvSxGUI 4bNsTiDRcfPxRHhWP36TmYJIVaeu9y7Hx7zO+ArWCWSDjGe3ysDpWk+1k3SO8grQqd91 1QWkZ238QxZg1vBgwflY7I9+pS043A5MTezZT9qF2SPIDLKVn1lqXzQQukcyaEUq4DFY Y4WHvUq12tiiTIf6I3VhTejLuGhuFJtgeYcYImIGD9tZb+MDEYrAiJUEtMRqQ/aCPGgy CVjRgRgmHJb4RDaMeLcDi8q5BGTjLHT/M+bJcW5G9QzjH1hdR+WnigLOr63JgwzsEMP1 N4LA== X-Gm-Message-State: AOAM533VqCKmmUUOKCdb34KCdKr0rs5M+OJmDZda+ChAAWwSl0aCviCl hMMZzTZ1EQE8Z+1A8XW99CNS+A== X-Google-Smtp-Source: ABdhPJz8mC+oy5QTxd+FVDFv22laevGRjje04Lf2wVUa8G+vhmhElanXbHdoiJIbuGw58hKsSQKOWg== X-Received: by 2002:a05:6512:2249:b0:478:f926:ad7 with SMTP id i9-20020a056512224900b00478f9260ad7mr38742258lfu.511.1655098500094; Sun, 12 Jun 2022 22:35:00 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id j2-20020a2e6e02000000b002555c9d5d7fsm894992ljc.11.2022.06.12.22.34.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jun 2022 22:34:59 -0700 (PDT) Message-ID: <647143fa-2521-10ae-2c4d-41dbb74d00cf@openvz.org> Date: Mon, 13 Jun 2022 08:34:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 From: Vasily Averin Subject: [PATCH mm v4 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: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Content-Language: en-US In-Reply-To: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655098501; a=rsa-sha256; cv=none; b=azeNhwuwoliRQ5klHwmY+VmIY4Kirf/6G8XcV7DpYs8RanpGez4WlNWGD1cpzTv7+IayfT LdPqvPKl97+mVSSzmR51i0PaqSDL3/Z0IUA/rphEoSKZWJ0Xq6jyXrUOlikik7GDENqH/l IleVpE+AHKW3hjvkneUgWOnhkgpcRK8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=poLeG6zh; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf07.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.48 as permitted sender) smtp.mailfrom=vvs@openvz.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655098501; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=IAnyg+25gOKjIFO+7ii4E6GwEOkKLUBizTS3t1OyQxTLk01Wr12MRDiRae8Xpdw7uOaFil 8UKQZUxCSjjELaWR5HUXOyGmjTmFjsRUp5Yi1w5+YXWgpgCmiQ9M35O0J5ZQOU7ZDWCBPP VDXORrFB+bbSucLEWGtgnppXahbyUCQ= X-Stat-Signature: znrudmpw7wpt47m8ahinau6taftmn33d X-Rspam-User: X-Rspamd-Queue-Id: 7DBE840071 X-Rspamd-Server: rspam07 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=poLeG6zh; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf07.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.48 as permitted sender) smtp.mailfrom=vvs@openvz.org X-HE-Tag: 1655098501-587745 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