Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3282861lfo; Mon, 23 May 2022 00:38:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCXPIidJThuOrnLuQKMLhxX8KcQHKCEwqo+tXTKS4yXB69c5Ud2H3ene6/KQDLauSXrVKV X-Received: by 2002:a17:903:2ca:b0:156:f1cc:7cb6 with SMTP id s10-20020a17090302ca00b00156f1cc7cb6mr22289127plk.174.1653291531449; Mon, 23 May 2022 00:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291531; cv=none; d=google.com; s=arc-20160816; b=xOZPrlOSIDzdEzmvo48EL/vQ+n7DhsgCPZ/Kn/l25y3bZZw4qiQOnfIaSUzPinVSR6 tYdWxQQgc68sPTYI66QtxP9KtqHMcWq6uEShfgrW9xlyJvSd1ZARQ3pqDusUOBQMQDtQ L10KjFha+XDeJYpBsNG63MqydHwOjBoo1oG0IbXg7b45Nj9itb5eMre4SAExkzZg8Cc1 tmzp2ua4usSE+y05sJFoStaeUEhwxD59BeC4rE8X84iP9MXmFCKjrWB8MxSEA2+jB9tv RfrTbxyAqewfP6HlZnY9GVVoe+gXtCU+iFDFQf5HJPStLURvPBlrQ9kY3/KMf0nTbZPG Sl0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=RmbAIVvF6HA8xSsvLvM24CBpM1SuThxarZu9EjTYW2g=; b=ZlMpojxCfEK20MwZobd0NbUF4zeQLO2UTYVmQ5mO6dQJcErBFK0PzfeLA/47YOCuPl j5ZYLcnE8slBOvhgroTZGlAxX7MtNPM9l2ZyWy3xJ+5I/lekc2+aNp/xK9sanr92cO85 UlRobydnRjRMEd9t0Y4BhCexuGYxsE23vtp63YGsEcRAzxS+2BOQ1A868+DMZkhd8E6i a4JWFESmwUT88Rz5IFsbv9RBv1vubetWKM2sLmLgjgjRDoJ9ybUw5mbrnZWLN9Cct65D tsoucycert7BPMoj9PB3E2L7PKKfvLt3bRC1SCSoyoZAh/Rcw8Uv4V8At7upl3syCTqy gYNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=M71piTm4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e4-20020a170902ef4400b00153b2d16577si9150857plx.383.2022.05.23.00.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:38:51 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=M71piTm4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4D581C15C4; Sun, 22 May 2022 23:46:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343767AbiEUQiT (ORCPT + 99 others); Sat, 21 May 2022 12:38:19 -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-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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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