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 6F90DCCA47C for ; Thu, 23 Jun 2022 14:51:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0953A8E015B; Thu, 23 Jun 2022 10:51:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 045D48E0144; Thu, 23 Jun 2022 10:51:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E77D78E015B; Thu, 23 Jun 2022 10:51:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D8E2B8E0144 for ; Thu, 23 Jun 2022 10:51:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id AF5E7808DA for ; Thu, 23 Jun 2022 14:51:05 +0000 (UTC) X-FDA: 79609788090.26.1EE65FC Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by imf23.hostedemail.com (Postfix) with ESMTP id 5FF371400AD for ; Thu, 23 Jun 2022 14:51:05 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id a2so33791359lfg.5 for ; Thu, 23 Jun 2022 07:51:05 -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=i/p1o/M8klz+95et0bgwJpltVKqCgK9M54afMq5vmjuCLAEfL2lvisExr0IgdMekvu tf1cimXjbPEFVWhzrSItzE1007SR0q12B7VZHtXazaQnKiyuWs4PSjAymxaW1j4O4P5d H3Jwm2v+2F+Bhhn5f1R8Q7OuwGM/ffLuUOy62bmulvutMKsnJhX/4NJnD4FRSVZQ/oZB R21gnYF30vDTNsNNc7Zri6ut8pZGbuCIKB51DHmUPpayYIR3ZTeU9z7xYQqjQ8TxdE1T UT5uMmYOuNDiJaGtg0ApIfWOb4pLIKsf7jLnMytt0GlIYkqXy4hVbvifv+enr8R0hnOM JuQg== 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=dshvrQR+UEfgZGKbXgOpJX/Oby58q3KInsU3ORk1H3VxkkJ/JBgeJBS2mthv8hpuo5 Aau/atXcjo3kr7UewysWO39boSq76RLu4hQXDBMHfwvky3uBdSlmYIZA1v279v6+fu86 aO3mcLiLqwkM1/t6QfV9JxqQO3xj8tlBgw+5IYX7VrBp7hRDIrga4OtV7+DAxew69DXc 6szOWOv0BiRir1qZSEWZIkJJIr7zjZeL/xO/kOcbYxaqjGsdtJnrxAyHOMWpihmDfeDN x14MJ6cATqPHFGvFPcrbQ18R+8uAY4tPUhLc4nf3Xl7Xy6h4vCkpJ8tZPrQQShMKQKWd qLOw== X-Gm-Message-State: AJIora+guzas+vnGRm+/4OpAJ8EESFnFKqg6WQHmeVqGqIFcOwuT+pnE AyY5mSvsGfNBs9VABmpws6dlHw== X-Google-Smtp-Source: AGRyM1s9nRJMZXHQY6aNsU9CgmRfXjPefvAMOQyBH3yS4iOM/J39zAOpv9yr4y+2zq9TSeoa52DsCg== X-Received: by 2002:a05:6512:2811:b0:47f:6d20:6a71 with SMTP id cf17-20020a056512281100b0047f6d206a71mr5674081lfb.60.1655995863995; Thu, 23 Jun 2022 07:51:03 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id s19-20020a2e2c13000000b002558e1bec75sm2827343ljs.5.2022.06.23.07.51.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 07:51:03 -0700 (PDT) Message-ID: Date: Thu, 23 Jun 2022 17:51:02 +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 v5 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: <4e685057-b07d-745d-fdaa-1a6a5a681060@openvz.org> Content-Language: en-US In-Reply-To: <4e685057-b07d-745d-fdaa-1a6a5a681060@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b="i/p1o/M8"; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf23.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.46 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=1655995865; 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=6X+Gcq2ElGgUnJQSu89yxnaJAvF05DhU2QQeihckfkSwLInAOvi2bZc9reLw2GYI39IfZN fdZ/TfKW45xETwFi81yj9Rn+3DdcTq9XmyG5UWjYOLsijqRNVENyZs+hD86RFY6/7jkAT4 DQGYQLCSWHSLauSynWS08dm8A5AD4J0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655995865; a=rsa-sha256; cv=none; b=CI5X5R0qnxOSvDAxJvaPd2PLMLiJgDhexOALL8zEJHOBVJU+MtxHtBgSg3kFbuY/KDXbW8 GF3G1JnfIYEsBg2tV8D6FjEZIMUkYAoQDL/j2Hs6ZL80pBmhkL447dOaQUOhXhificpsif mHa8myx8jR3LAM6HQAmWyFXkL0RjyPo= X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b="i/p1o/M8"; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf23.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.46 as permitted sender) smtp.mailfrom=vvs@openvz.org X-Stat-Signature: o8crktgrr654fiinxp8mgjd3qoc36sxh X-Rspamd-Queue-Id: 5FF371400AD X-Rspamd-Server: rspam12 X-HE-Tag: 1655995865-101809 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