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 5D9BBC433EF for ; Sat, 21 May 2022 16:38:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E44B16B0082; Sat, 21 May 2022 12:38:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCC996B0083; Sat, 21 May 2022 12:38:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C460B6B0085; Sat, 21 May 2022 12:38:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AE63E6B0082 for ; Sat, 21 May 2022 12:38:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 72A59806D3 for ; Sat, 21 May 2022 16:38:14 +0000 (UTC) X-FDA: 79490307708.23.CFBB668 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf12.hostedemail.com (Postfix) with ESMTP id D27934001D for ; Sat, 21 May 2022 16:37:41 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id p4so17587059lfg.4 for ; Sat, 21 May 2022 09:38:13 -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=RmbAIVvF6HA8xSsvLvM24CBpM1SuThxarZu9EjTYW2g=; b=M71piTm4QZ2DLh7IhmfELsYTvMjovz64N6L4bc7j7NKyHPlOrc2Zi9Xwk38DW64VN+ 7bH5RKLiIHTSQpVq+jOGo3auyXvFr+ZKHqS4gcHwTZm1EIykS44nrpPaLiYLVyfTiHEe xKLSGhYsd0plkaeN/1Jvr53qHXecz6RYfUSZrDvrkMfxtCeZPAjjEc98ScxJ4sM6HJXK oOd8QKCzmgM3xikU3DAVc1HkiumoMe5ymxFZCvjWB2fnVHLi10YLibLTSX/wXOUkAEFZ KlEbX6CEFOKKGiVh3E0J5iiAHnMRS6ua48EE4OPGd8SAMk3Rd/wdSn9aM5tYwh98PtQ7 LLPA== 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=RmbAIVvF6HA8xSsvLvM24CBpM1SuThxarZu9EjTYW2g=; b=SDkrgYPXs6plJTe9jJ7TnnyoGJ8v2W0LpTYIyRhwEBRmOUIl9lIiWKAsH2VxmLyFBV 5H/1eSDftgcFFekyFC3iljR2jVJzKtB4lzMwUfWLQhz6oIM1aqcWDae4CsG+Rxv3l7cf 8wuCc31QvjccKrMsJwgrfSHuTAVd0BzEQVfuy4wzttMDOWoZRmmAYIodWNF9iFDe4331 66nVlb4ing5rCZs9qf62kqPY4CIv6Xtd5G1UiMxvp4zlgLnH6jagrmRx1Rej6dQvIriC NNnXnOYuO6WWEsuLpGaztIHmKx8Azo1o3c7sW7dnCXWoR0minDt8TZd8Dy/uvFNywolZ PS5Q== X-Gm-Message-State: AOAM532zFoCLP/CINdbjgwEGc1d5bQhFA5L7G84O3XkBeauqm17F0q5Z UVRI1VasLE1ICVeSQMzqV2hQBA== X-Google-Smtp-Source: ABdhPJxi3Tmu3Z2yv3O/1Nib/iVtyL3aPOp6WRbOKPKbZRX6++ivLJPbV1LaKb0QhUqpaJtfJ02HOA== X-Received: by 2002:a05:6512:1588:b0:477:a556:4ab2 with SMTP id bp8-20020a056512158800b00477a5564ab2mr10655943lfb.376.1653151092288; Sat, 21 May 2022 09:38:12 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.185]) by smtp.gmail.com with ESMTPSA id u6-20020ac258c6000000b0047255d210dbsm1123031lfo.10.2022.05.21.09.38.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 May 2022 09:38:12 -0700 (PDT) Message-ID: Date: Sat, 21 May 2022 19:38:11 +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 4/9] memcg: enable accounting for struct simple_xattr 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: D27934001D X-Stat-Signature: 81ftt3hjrj5764dr4ab9iuaoisk3ag8o Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=M71piTm4; dmarc=pass (policy=none) header.from=openvz.org; spf=pass (imf12.hostedemail.com: domain of vvs@openvz.org designates 209.85.167.50 as permitted sender) smtp.mailfrom=vvs@openvz.org X-Rspamd-Server: rspam04 X-HE-Tag: 1653151061-280286 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 1 32 (simple_xattr_set+0x59) 1 8 (__kernfs_new_node+0x30) '+' -- to be accounted This patch enables accounting for struct simple_xattr. Size of this structure depends on userspace and can grow over 4Kb. Signed-off-by: Vasily Averin Reviewed-by: Roman Gushchin Reviewed-by: Michal Koutný Acked-by: Shakeel Butt --- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xattr.c b/fs/xattr.c index 998045165916..31305b941756 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -950,7 +950,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size) if (len < sizeof(*new_xattr)) return NULL; - new_xattr = kvmalloc(len, GFP_KERNEL); + new_xattr = kvmalloc(len, GFP_KERNEL_ACCOUNT); if (!new_xattr) return NULL; -- 2.36.1