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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C7C3C433EF for ; Sat, 21 May 2022 16:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350665AbiEUQiV (ORCPT ); Sat, 21 May 2022 12:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344944AbiEUQiQ (ORCPT ); Sat, 21 May 2022 12:38:16 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7A7460DBE for ; Sat, 21 May 2022 09:38:13 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id p4so17587049lfg.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=N9gp5gHa3yrjs/gK+MLCKgVZbq3Ke4I5I6gcWEzcBbr0WRF9a9qatV2xInqKhijGFB Mktj6Jtrur7wfOX/Rqk8QKcuHJs+XvPtfnw1XrAGGR+f43PEPSiyLRPaaojdjj51dfK/ yshxNEUiDSZXk2DYORJU5N6SrgQc3Fp9pkQadbUOTS5NImRh54toXyGs9CBS+hDlEbFc dB7dS8yc8WfmxfSAfxYQ+OYi+3SovrMkxGRwAh1cTvC/ERKlOOYm3Gl82tRdkiAufbVl a2KwCwGH6f9UBv52JyOmbnpmep+I4OH0VKjW2z1mbzhc1BgIF01Q2mUwYzODLPeRY/Wo MKKg== X-Gm-Message-State: AOAM533oJ7RYkeh1EzJAx69WwFR7WPMErDaQtDi1wZdyaiWBxwnmwkCa aXzB5t2M/Ib8wajWqu4Z0yf8RA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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