Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5920188iog; Thu, 23 Jun 2022 07:53:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t29QBVLMKh47TlRuF9yFo/0v+szo0utuf4rXM47FKwzUOZ4Ru7jacOjqvXa6R8rVSGP3V+ X-Received: by 2002:aa7:cb13:0:b0:433:4985:1b54 with SMTP id s19-20020aa7cb13000000b0043349851b54mr11187871edt.182.1655996012267; Thu, 23 Jun 2022 07:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655996012; cv=none; d=google.com; s=arc-20160816; b=ZbCjngoHOS6IeKNXir4TME6nlJNhdnoGDj1cUkQ9O7tI+fOmy8N3iUbMPsYvEPrElz /sF0aNvLGP7/6DtBpZjeqZMDsyLIy/43hH+27m37AmHjBLPc4662+VlpnOresoKOrQSM QWUSc/PULJQS7cTEEC87ehrKQYzep4ybyr1J3QyIB+dsasOXRLWEcU5juoeXZJYm6kNz XrelqRDs6T/B7T1OSaSgxiWn7xyn7dPVQEVAmdA006DCZ4BiWKgINYfxSijZk9IKbyve mtI4BBID/4tqBU1ccGzvTrpep4lB2zB1jUeJolWVejYnQreB/TrgcEbxYtz2LoM6uy0p Xexw== 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=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=axlx2lmYW8Q33FuPxDGOXWmOjO0dT3GVFh1rMus2qMyFmnhp00ZDMixJTy9l5nn3ys erhXP5zGToiAknN8EWWOQthwDIvUB3Tnj+98FvbumV9dL9vwXkr3JYjHWA/5ZP+LggQs ItBCjGBXbx9O19smo8bPMzQNreyc7T43Og9MBU1aJRnjk5ECsp2N79yeRwBoh3iz4pf8 dNCIW2jRi6cVrw7mYYSrHwBXN0O0183WU7z39LvBuCBWeJx7JdS6mslo+lsnCdZPxLPh 4iHECCaH5oNFnSy/whvRKmlikfdycYqFZp9ZbftD/Dy+jMqRIoJGjlsXYOpH3a6o9e6H YJDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b="i/p1o/M8"; 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 q4-20020a056402248400b00435640bfdc8si8065069eda.199.2022.06.23.07.53.05; Thu, 23 Jun 2022 07:53:32 -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="i/p1o/M8"; 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 S232036AbiFWOvK (ORCPT + 99 others); Thu, 23 Jun 2022 10:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231890AbiFWOvH (ORCPT ); Thu, 23 Jun 2022 10:51:07 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE6146CA9 for ; Thu, 23 Jun 2022 07:51:05 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id w20so33753143lfa.11 for ; Thu, 23 Jun 2022 07:51:05 -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=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=i/p1o/M8klz+95et0bgwJpltVKqCgK9M54afMq5vmjuCLAEfL2lvisExr0IgdMekvu tf1cimXjbPEFVWhzrSItzE1007SR0q12B7VZHtXazaQnKiyuWs4PSjAymxaW1j4O4P5d H3Jwm2v+2F+Bhhn5f1R8Q7OuwGM/ffLuUOy62bmulvutMKsnJhX/4NJnD4FRSVZQ/oZB R21gnYF30vDTNsNNc7Zri6ut8pZGbuCIKB51DHmUPpayYIR3ZTeU9z7xYQqjQ8TxdE1T UT5uMmYOuNDiJaGtg0ApIfWOb4pLIKsf7jLnMytt0GlIYkqXy4hVbvifv+enr8R0hnOM JuQg== 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=buhJIxm8AqBO3bD99fC3A2PxIb9sSGllubXvwSLnjxI=; b=ooavryFFdV7JF9tZCP+h5KoaVXP8jEpe5acR0aTbIQO1rDVF+/KqNokotUoeM1GssZ zYAXCs+icAt+8sWAPqlbybwl2HoOZeKONk1nOzn0LTMU/EMfXrI+dNL0d1EH09jG0IZR WXYPOJjBF9/ipZlnSE7FY6PY/x1IRMn7Bhk1MKlDYDJkUAP+05NvsveCXTJPUQmJZmeq x2Lkj0wyK8aZsoUEX/WGG75y6fTihc+YYZ9Di/nQUCA3fL+axKubSw2aD2HXlH1x+vcq FYYVat48szHNnCdBLWDDIFj/GQVK3hz/TEvAb+uzVYc//8A3mcW1sQP18fmK3ziHRPOa QG4w== X-Gm-Message-State: AJIora9E8kfm3TYMoWqyHtQ6fGpiLTB2XDWntbIj2nSsuP5abev6sgFU 2q6O/VleRU76SQaLH2TuKSt5Gw== X-Received: by 2002:a05:6512:2811:b0:47f:6d20:6a71 with SMTP id cf17-20020a056512281100b0047f6d206a71mr5674081lfb.60.1655995863995; Thu, 23 Jun 2022 07:51:03 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id s19-20020a2e2c13000000b002558e1bec75sm2827343ljs.5.2022.06.23.07.51.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 07:51:03 -0700 (PDT) Message-ID: Date: Thu, 23 Jun 2022 17:51:02 +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 3/9] memcg: enable accounting for kernfs iattrs 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=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, can grow over 4Kb 1 32 (simple_xattr_set+0x59) 1 8 (__kernfs_new_node+0x30) '+' -- to be accounted This patch enables accounting for kernfs_iattrs_cache slab cache Signed-off-by: Vasily Averin Reviewed-by: Roman Gushchin Reviewed-by: Michal Koutný Acked-by: Shakeel Butt Reviewed-by: Muchun Song --- fs/kernfs/mount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 3ac4191b1c40..40e896c7c86b 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -397,5 +397,6 @@ void __init kernfs_init(void) /* Creates slab cache for kernfs inode attributes */ kernfs_iattrs_cache = kmem_cache_create("kernfs_iattrs_cache", sizeof(struct kernfs_iattrs), - 0, SLAB_PANIC, NULL); + 0, SLAB_PANIC | SLAB_ACCOUNT, + NULL); } -- 2.36.1