Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4066103ioo; Mon, 30 May 2022 17:14:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh/GLDp8LLn3e1DNCFPRReQowd74kZBTMSnxitb0CH116WDs76h7BJRPSokf0TwfBO7lEY X-Received: by 2002:a05:6402:a4f:b0:42d:db40:f685 with SMTP id bt15-20020a0564020a4f00b0042ddb40f685mr4165450edb.384.1653956040532; Mon, 30 May 2022 17:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653956040; cv=none; d=google.com; s=arc-20160816; b=SD3RCvUncu/If0fD2U1SNPyYDCNAWrmU8pvvhgBaX10FsNLbYQLMwHd3BDBIioT+FY IQX2MUKGyguVllESh3kDG1hipGL7gpfpTMoqQYReyKlDu3/RtRjJJgKxuFACkhu6GKB/ +aikXv0F9cnn3Gw+rtHl1MWG91Bx3FNBik8uflp4EQTYqXp3dRDntYneax8NU8Khg3/F PSzVgqxwix/XtzYtoQXGXH2qxXPCB5RjbS556/vuwV/zpSN/hjqhihW/sK8nSgRb8bxe ryjY5Mwe8Ma4otjbQvX3kNfPniTIAs8vfQ4sMMdS03qH7/hjHwIhhr4fcUC0c4+C5DVZ ie6Q== 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=k8OfFf3zteeGV4NoXsW7mYQBRm/UT3jxMOm3SilJFI0=; b=iUh6rujmJoDv/QQDYV2Evb/3DJkqhT8+n2ispyi2T+C7FawMOwIWtgyneoU1LIdRIG jeibIqimQCs3x543ls4tBXWUnqAvcTWtAKd8YzgrQYIQ9ZAdYq43FHEeKxr5ar13947a TzWTx6iHDQSCbbR60a8ydPhxl13Tra+5FlMAvYuJaljiyypcMBJgAAAJa4OwqbhSMUlu K+UfsMOqzd8kzSMp/54QvGxwEBKhdgKaG9vHfVOnvVHSWnkRJcktJx0e3qRMeQ0/eJQC eKI1ExTC/1jZb5MXNkEaa5gRaWWXrko86DpdPmxfCw7yWk0rJrckEZiifELXvI5/QJEb NznA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b="K/QFxlOD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a056402238600b0042cef1a5696si186998eda.432.2022.05.30.17.13.25; Mon, 30 May 2022 17:14:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b="K/QFxlOD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235709AbiE3L0X (ORCPT + 99 others); Mon, 30 May 2022 07:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235712AbiE3L0W (ORCPT ); Mon, 30 May 2022 07:26:22 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17C187E1CE for ; Mon, 30 May 2022 04:26:20 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id p4so16289528lfg.4 for ; Mon, 30 May 2022 04:26:20 -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=k8OfFf3zteeGV4NoXsW7mYQBRm/UT3jxMOm3SilJFI0=; b=K/QFxlODFRAVf5bt4Q3P/XNh1C8S/u5UgjkwbSrQRpQsAlAfqwyev+c+gKJa7sqM/E oQZSKjl/uojTT/rpHIvx0MAm4K8ZHdoT5kwFjZRwHOZa9yv6Ym6HisUbdsUdy1+BkCLn L5peMyjN5TEkxZCi/h1dH+nfo5XsybR/iIDzcJRIdXQ0oMZgtKynvBMNcuWwSJHRivKh c/tAJLVDRKtzyZ4IydneAMA8SrsOIVPc4G+J/qRvjIB/Xw7o9KziSEBXV6+2XhpiVWaP BiXPrksHoHCXi3svqTtexh4P+jYBn5XvE4noKsvPXrztol0mmqbsUK7ATZjq+fvDxVg4 DyaQ== 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=k8OfFf3zteeGV4NoXsW7mYQBRm/UT3jxMOm3SilJFI0=; b=60iRsTWfcvD66vf4tKyI9VqTTB7jocK4C3Ow31GbP0TO91AaBGsI0/AWmGol72Hi+X 6NkWU9U0SaM+7EBVZctLoXNfyHYqb49w2Nxi88WfJ5wDvGTBxgpltPpheUXeCv4aBaiF l7nPilBJLteJd0F/IJF6HI9xrwpEYRKM4qTh/+Fapt28fGQmmd8nlt5dMjBp7g8VLgJ+ dOTTG2H6IIVvPPpMKmCWi5+gbDGluF759rm4sLbLafmaeYllOjydo/tXYQYclX9FH56r 4aV7UB/Oy8dvQsMlQ57XltJI0I/Vkw8560flhr777vj+F8Mipfs/LIgGLrVecLDG766f aK6A== X-Gm-Message-State: AOAM532cJqm954LLmS4Dk2EQpq5Zug04WiYoFo1nVDCGMMXSsXYdCB8f MaAewM8jNQlbPsTp2oBCCWS9Hw== X-Received: by 2002:a05:6512:2304:b0:477:a99b:53e4 with SMTP id o4-20020a056512230400b00477a99b53e4mr40004522lfu.445.1653909979299; Mon, 30 May 2022 04:26:19 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id bf14-20020a2eaa0e000000b002555232be9asm196311ljb.83.2022.05.30.04.26.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 04:26:19 -0700 (PDT) Message-ID: Date: Mon, 30 May 2022 14:26:18 +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 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 , 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Reviewed-by: Muchun Song --- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xattr.c b/fs/xattr.c index e8dd03e4561e..98dcf6600bd9 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -1001,7 +1001,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