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 B70C3C433FE for ; Mon, 30 May 2022 11:26:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 394776B0081; Mon, 30 May 2022 07:26:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 342D96B0082; Mon, 30 May 2022 07:26:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2057A6B0083; Mon, 30 May 2022 07:26:03 -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 133DA6B0081 for ; Mon, 30 May 2022 07:26:03 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id DED3560EFA for ; Mon, 30 May 2022 11:26:02 +0000 (UTC) X-FDA: 79522180164.30.0ADCF01 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf24.hostedemail.com (Postfix) with ESMTP id E9ECF18004D for ; Mon, 30 May 2022 11:25:47 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id e4so11268664ljb.13 for ; Mon, 30 May 2022 04:26:02 -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=gx5BulmdWVt1E6J23Q6sWTUkZpDqVLFQzvPT6hFPLlw=; b=HI2S3D2LaM+CpJncitps90D3zTHWFeNVbRo1proDv/epa86UIsO3B+emCKjHD05m4E qaz6ChKh6pu6uXKvY4S+1hqcRalF7rqVye6N2mRkVsZBcCOfpslnrDjEWUzDp+5aaXyk tX2/q17/WDl//b5r1mGa7Tq3zVSZPou91Tp/ZcFweUHcJ2JUTj+EhVRNwd5zDCtSX0FG 7cSJ76MxlShzeRJ6K2QGxobnEb8yF6DKMGiaLkKYKeKo38m8hCPfsMYL2Hm+58LsRZDB drNrbEsCzPbVlFCfAbrszHoJLFdt1COVb1PrGklTomSfK6+fAnL5CpYezD9s7NiYDo8P IWbQ== 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=gx5BulmdWVt1E6J23Q6sWTUkZpDqVLFQzvPT6hFPLlw=; b=bM2MAQThtYB9Y3Wx/GqvvPM7oSdKxlc7I6RGJbssFa7i7kQVsIZMH9vdxpVSst9+JI lKsIaG8GLZ0If0RoFV4bDjSwpFukbLkBbWd3WnKls18HMExqXGIg+W5swwU9ug2MvoCT bnq/+7crcyq9udZydlSXDa9x/ALLIfdZrm3IuD4KUfNym2ujdZoyRDVYfM0tca/9vA+E XqYqZ9vIkSfDEO9tcq3Z4NkFtqpEdBl+DHTpTkWdh0j+x89XHa2vR4hyPSG/uYncitM6 BXKixAOcvP+/Fv1CQ7wgHwp9UENicO75jp/SEsYNY31n5ugDkwJqyqBHtoY6rGM8g3jM 8/HQ== X-Gm-Message-State: AOAM531oEjJVhUxClr0I9PfQK4xDxlOFlV2OTZ2YVzJUlXxufBV4Y6aM TmV647YjuOCZRCWRNLescqEDBA== X-Google-Smtp-Source: ABdhPJwD9LSfSBRnWiwlpIefSTvogQriUgx1hTSg0IhVk8GLzaUQIgiJC9ckHwGLQaN1U8YmUtU/eQ== X-Received: by 2002:a05:651c:556:b0:255:5125:309 with SMTP id q22-20020a05651c055600b0025551250309mr1693556ljp.201.1653909961957; Mon, 30 May 2022 04:26:01 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id d16-20020ac244d0000000b0047255d21188sm2255883lfm.183.2022.05.30.04.26.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 04:26:01 -0700 (PDT) Message-ID: Date: Mon, 30 May 2022 14:26:00 +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 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 , 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: E9ECF18004D X-Stat-Signature: mtxbwh175mdo96q6he7j69qn8b4gzg76 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=HI2S3D2L; spf=pass (imf24.hostedemail.com: domain of vvs@openvz.org designates 209.85.208.175 as permitted sender) smtp.mailfrom=vvs@openvz.org; dmarc=pass (policy=none) header.from=openvz.org X-HE-Tag: 1653909947-291091 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 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.36.1