Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5947304iog; Thu, 23 Jun 2022 08:20:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sPqmJsKR2lZ5XjhzDOdZDySIjByin+0HzlzX053qpExHa20PlX1j85Esnql4PGuxn2ZocP X-Received: by 2002:a05:6402:653:b0:435:5aaf:20e7 with SMTP id u19-20020a056402065300b004355aaf20e7mr11345279edx.125.1655997608731; Thu, 23 Jun 2022 08:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655997608; cv=none; d=google.com; s=arc-20160816; b=psLIJ8fqgMfnm5eJQz0w4ukV6m1Kj+Ae5rkVNEf0W+JBVfk3BgBxx+fbJ3RZ22l6NK eDAElj5oBpKpsi3IJ/AvPu7c4hNcwk7fMMipEnVbmSySu5Eha+ydUVpWQMGf+/MK4cIR wnDRBnhD32jqgTjBn7k+b4s9za+dwyPDRh1JxS5oEl9tr9SQ7UorTbTOgpLeE8axHXKZ E6FjkhPmWiWrP7wrpmpibbu0wt8+rLjBoqHLu9MH6uGtnCQ7MpILca51EMIpjlnVynbP JBSywTcflShrezulRXbjj6uWWIMAbELEZ6Q//fJCfHEjYt1C9adRijeiPXJQFcrQsXeY ysqQ== 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=tCA1jIX0iP9cc6ifR62y8W88Zdbgo8fbGHsvDYpknLcxH3JVPcVeRLI2sysMrAHZR7 D8QBE0R9cD0H5Si4GGpQA1lkZ+bpnoVRboLdQ+4Y8EHnryf84nT1WiYkyA1skImZ6jHM wLmwYsJ8s12ezQ+c87CPLsPW/0wcujiHMr8lbnDugRjULI5EEePzksYgtRSPiO3vXVU+ +PVYMQHwXxDnpyINbWfqLiyuRCH8BR62Z83V1ZodcBVUCbsGFL69tRtZEDDB2V+jTWo3 lE/KFnKKgVh4jbPVnWQ0h7aqJF9vps5Yhnuo2VbjdVg8kVrglUvI6h8UJFglwSsi7J0X qdBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=hsg2w+ab; 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 9-20020a17090602c900b00722a7e9e642si13605957ejk.587.2022.06.23.08.19.42; Thu, 23 Jun 2022 08:20:08 -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=hsg2w+ab; 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 S231846AbiFWOvY (ORCPT + 99 others); Thu, 23 Jun 2022 10:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231890AbiFWOvR (ORCPT ); Thu, 23 Jun 2022 10:51:17 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DD54707B for ; Thu, 23 Jun 2022 07:51:13 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id s10so23575592ljh.12 for ; Thu, 23 Jun 2022 07:51: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=k8OfFf3zteeGV4NoXsW7mYQBRm/UT3jxMOm3SilJFI0=; b=hsg2w+abNmxBuNt4Iv4r+V21/tVetnU4U/D2SV+gm392hJCFDklntUJOdfxD3yiiPB MvGH3he8zMgV8AYjS8QEzaWnf3xrJB9UhPqWdSpP+22GycMOwBSKrGK7aJI0AfhBEPL2 2NAxJyMQ816jqIBDzXSq4r4bLuH82L0hneLKdzdBxFx3SI+2TxhhWeT7s/0YEabpfnTG 6MBUo28BBuCeUwV6cMOrM0zubkHeEB1KFTTA4V0riTQBjXFDcFelIFctLJlb4yTs7sM7 XEx9XLZ9Sh20UTK7vVfDEkaniIvsLVt0dL4fjbigg+OME17vZ4F8f7WcUs3ubT10zDlJ FNbw== 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=e8m4VZCpp3xVVM+ktPz2evq4KHJbmyDxtRGHIavVR+rcZqD9YaxMR5RuaZkQwUM6T+ XsM4MSqCKCz7O7zkziKhKiI3sfecXYqNQeeKrBpimKHm5JT1CJSDWd9iBHnQ7TwUisO9 SVgwGM1bjxkY6tPFQQoIxOgqNVkHMxkBxAEYgNN9kmEcO819ATD7NC1RmiH0ZaVRK0b6 F0mgZL9JfSgwLrwFACrklcghGX4lKLE6zuIKxzVxpfnsk53FT7VZLrrdVNJXRAjx2TxI sRYKfCG85gaQbLL6aWfU7INuaq8vjHpiOBFnKPq8m1FgDK+K6IOCM2wvFzf9Ccmjrkur OCdw== X-Gm-Message-State: AJIora99Nu9waL7COVgsjMGafcDzOueRVX8Za3nsiiOVHynRFAWLiyKF t9Cyn9kwJ9rnY5hYld+MLH/H9g== X-Received: by 2002:a05:651c:11c1:b0:25a:8968:b834 with SMTP id z1-20020a05651c11c100b0025a8968b834mr4871877ljo.212.1655995872261; Thu, 23 Jun 2022 07:51:12 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id a4-20020a19ca04000000b0047255d210dcsm2247637lfg.11.2022.06.23.07.51.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 07:51:11 -0700 (PDT) Message-ID: <97e05495-d74e-275c-0739-8abff974cdc5@openvz.org> Date: Thu, 23 Jun 2022 17:51:11 +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 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: <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 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=ham 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